mirror of
https://github.com/Dasemu/meta-social-mcp.git
synced 2026-11-27 15:56:55 +00:00
Add carousel posts and local media upload
- publish_post now accepts a `media` array (2-10 items) to publish Facebook multi-photo/video posts and Instagram carousels. - New upload_media tool: takes base64 file content and serves it publicly under this server's own domain, so local images/videos can be turned into the public URL Meta requires without a tunnel. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ea3841512
commit
a38494db5c
6 files changed
+231
-12
No files matched your search
@@ -21,3 +21,16 @@ HOST=127.0.0.1
|
|||||||
# Token opcional para proteger el endpoint /mcp (header: Authorization: Bearer <valor>)
|
# Token opcional para proteger el endpoint /mcp (header: Authorization: Bearer <valor>)
|
||||||
# Dejalo vacio para desactivar la comprobacion (solo recomendable en local/dev)
|
# Dejalo vacio para desactivar la comprobacion (solo recomendable en local/dev)
|
||||||
MCP_AUTH_TOKEN=
|
MCP_AUTH_TOKEN=
|
||||||
|
|
||||||
|
# URL publica (con path si aplica) desde la que se sirven los archivos subidos
|
||||||
|
# con upload_media, ej: https://mcp.zenvairo.es/zenvairosocial
|
||||||
|
MEDIA_BASE_URL=
|
||||||
|
|
||||||
|
# Directorio donde se guardan los archivos subidos (por defecto ./media)
|
||||||
|
MEDIA_DIR=
|
||||||
|
|
||||||
|
# Tamano maximo (MB) de un archivo subido con upload_media
|
||||||
|
MAX_UPLOAD_MB=50
|
||||||
|
|
||||||
|
# Dias que se conservan los archivos subidos antes de borrarse automaticamente
|
||||||
|
MEDIA_RETENTION_DAYS=7
|
||||||
@@ -68,7 +68,8 @@ claude mcp add --transport http socialmcp http://127.0.0.1:3300/mcp
|
|||||||
|
|
||||||
| Herramienta | Qué hace | Endpoint(s) Graph API | Permisos necesarios |
|
| Herramienta | Qué hace | Endpoint(s) Graph API | Permisos necesarios |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| `publish_post` | Publica ya en Facebook y/o Instagram (texto, imagen, video o enlace). Instagram exige `imageUrl` o `videoUrl`. | `POST /{page-id}/feed`, `/photos`, `/videos` · `POST /{ig-id}/media` + `/media_publish` | `pages_manage_posts`, `pages_show_list`, `instagram_basic`, `instagram_content_publish` |
|
| `publish_post` | Publica ya en Facebook y/o Instagram: texto, imagen, video, enlace, o un **carrusel** (2-10 elementos) via `media`. Instagram exige `imageUrl`/`videoUrl`/`media`. | `POST /{page-id}/feed`, `/photos`, `/videos` · `POST /{ig-id}/media` + `/media_publish` | `pages_manage_posts`, `pages_show_list`, `instagram_basic`, `instagram_content_publish` |
|
||||||
|
| `upload_media` | Sube un archivo local (base64) y devuelve una URL pública servida por este mismo servidor, para usarla en `publish_post`. | — (no llama a Graph API) | — |
|
||||||
| `list_posts` | Lee el histórico de publicaciones propias (FB o IG). | `GET /{page-id}/posts` · `GET /{ig-id}/media` | `pages_read_engagement`, `pages_show_list`, `instagram_basic` |
|
| `list_posts` | Lee el histórico de publicaciones propias (FB o IG). | `GET /{page-id}/posts` · `GET /{ig-id}/media` | `pages_read_engagement`, `pages_show_list`, `instagram_basic` |
|
||||||
| `list_comments` | Lista comentarios de un post/media propio, o respuestas de un comentario. | `GET /{object-id}/comments` | `pages_read_engagement`, `pages_manage_engagement` (FB) · `instagram_basic`, `instagram_manage_comments` (IG) |
|
| `list_comments` | Lista comentarios de un post/media propio, o respuestas de un comentario. | `GET /{object-id}/comments` | `pages_read_engagement`, `pages_manage_engagement` (FB) · `instagram_basic`, `instagram_manage_comments` (IG) |
|
||||||
| `get_comment` | Lee el detalle de un comentario por ID. | `GET /{comment-id}` | igual que `list_comments` |
|
| `get_comment` | Lee el detalle de un comentario por ID. | `GET /{comment-id}` | igual que `list_comments` |
|
||||||
@@ -78,12 +79,30 @@ Todos los permisos anteriores requieren, además, `business_management` si la ap
|
|||||||
activos gestionados desde Business Manager, y que la app haya pasado **App Review** de Meta para
|
activos gestionados desde Business Manager, y que la app haya pasado **App Review** de Meta para
|
||||||
usarlos fuera del modo de desarrollo/testers.
|
usarlos fuera del modo de desarrollo/testers.
|
||||||
|
|
||||||
|
### Carrusel (varias imágenes/videos en un post)
|
||||||
|
|
||||||
|
Pasa `media: [{ url, type }, ...]` (2 a 10 elementos, `type` es `"image"` o `"video"`) en vez de
|
||||||
|
`imageUrl`/`videoUrl`. En Facebook cada elemento se sube sin publicar y se referencia desde el post
|
||||||
|
via `attached_media`; en Instagram se crean *child containers* (`is_carousel_item=true`) agrupados
|
||||||
|
en un container padre `media_type=CAROUSEL`.
|
||||||
|
|
||||||
|
### Subir contenido local (`upload_media`)
|
||||||
|
|
||||||
|
Meta exige que `imageUrl`/`videoUrl` sean URLs públicas — no vale una ruta local. `upload_media`
|
||||||
|
recibe el archivo codificado en base64, lo guarda en `MEDIA_DIR` y lo sirve en
|
||||||
|
`MEDIA_BASE_URL/media/<archivo>` (el mismo dominio público donde ya corre este MCP, sin necesidad
|
||||||
|
de un túnel aparte). El resultado se pasa directamente como `imageUrl`/`videoUrl`/`media[].url` a
|
||||||
|
`publish_post`. Los archivos se borran automáticamente pasados `MEDIA_RETENTION_DAYS` días (por
|
||||||
|
defecto 7), y el tamaño máximo por archivo es `MAX_UPLOAD_MB` MB (por defecto 50).
|
||||||
|
|
||||||
## 7. Limitaciones importantes
|
## 7. Limitaciones importantes
|
||||||
|
|
||||||
- **Instagram no admite publicaciones de solo texto**: siempre necesita `imageUrl` o `videoUrl`
|
- **Instagram no admite publicaciones de solo texto**: siempre necesita `imageUrl`, `videoUrl` o
|
||||||
accesible por una **URL pública** (no vale una ruta local ni una URL que requiera login).
|
`media`, accesibles por una **URL pública** (no vale una ruta local ni una URL que requiera login;
|
||||||
- Los videos/reels de Instagram necesitan tiempo de procesamiento: `publish_post` espera
|
usa `upload_media` para convertir un archivo local en una URL pública).
|
||||||
automáticamente (hasta 60s) a que el contenedor esté listo antes de publicar.
|
- Los videos/reels de Instagram (y los elementos de video en un carrusel) necesitan tiempo de
|
||||||
|
procesamiento: `publish_post` espera automáticamente (hasta 60s por elemento) a que el contenedor
|
||||||
|
esté listo antes de publicar.
|
||||||
- Instagram no tiene programación nativa de publicaciones ni este servidor la implementa;
|
- Instagram no tiene programación nativa de publicaciones ni este servidor la implementa;
|
||||||
`publish_post` publica siempre de inmediato.
|
`publish_post` publica siempre de inmediato.
|
||||||
|
|
||||||
|
|||||||
+69
-3
@@ -11,7 +11,7 @@ async function graphRequest(path, { method = "GET", params = {} } = {}) {
|
|||||||
const url = new URL(`${BASE}/${ver()}/${path}`);
|
const url = new URL(`${BASE}/${ver()}/${path}`);
|
||||||
const qs = { ...params, access_token: token };
|
const qs = { ...params, access_token: token };
|
||||||
Object.entries(qs).forEach(([k, v]) => {
|
Object.entries(qs).forEach(([k, v]) => {
|
||||||
if (v !== undefined && v !== null) url.searchParams.set(k, v);
|
if (v !== undefined && v !== null) url.searchParams.set(k, String(v));
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = await fetch(url.toString(), { method });
|
const res = await fetch(url.toString(), { method });
|
||||||
@@ -26,7 +26,10 @@ async function graphRequest(path, { method = "GET", params = {} } = {}) {
|
|||||||
|
|
||||||
// ---------- Publicacion: Facebook Page ----------
|
// ---------- Publicacion: Facebook Page ----------
|
||||||
|
|
||||||
export async function publishFacebookPost({ pageId, message, imageUrl, videoUrl, linkUrl }) {
|
export async function publishFacebookPost({ pageId, message, imageUrl, videoUrl, linkUrl, media }) {
|
||||||
|
if (media && media.length >= 2) {
|
||||||
|
return publishFacebookCarousel({ pageId, message, media, linkUrl });
|
||||||
|
}
|
||||||
if (videoUrl) {
|
if (videoUrl) {
|
||||||
return graphRequest(`${pageId}/videos`, {
|
return graphRequest(`${pageId}/videos`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -45,9 +48,38 @@ export async function publishFacebookPost({ pageId, message, imageUrl, videoUrl,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FB multi-foto/video: cada elemento se sube sin publicar y luego se referencia
|
||||||
|
// desde un post de feed via attached_media.
|
||||||
|
async function publishFacebookCarousel({ pageId, message, media, linkUrl }) {
|
||||||
|
if (media.length < 2 || media.length > 10) {
|
||||||
|
throw new Error("Un post multi-foto/video de Facebook admite entre 2 y 10 elementos");
|
||||||
|
}
|
||||||
|
const attachments = [];
|
||||||
|
for (const item of media) {
|
||||||
|
const isVideo = item.type === "video";
|
||||||
|
const uploaded = await graphRequest(`${pageId}/${isVideo ? "videos" : "photos"}`, {
|
||||||
|
method: "POST",
|
||||||
|
params: isVideo
|
||||||
|
? { file_url: item.url, published: "false" }
|
||||||
|
: { url: item.url, published: "false" },
|
||||||
|
});
|
||||||
|
attachments.push({ media_fbid: uploaded.id });
|
||||||
|
}
|
||||||
|
|
||||||
|
const params = { message, link: linkUrl };
|
||||||
|
attachments.forEach((att, i) => {
|
||||||
|
params[`attached_media[${i}]`] = JSON.stringify(att);
|
||||||
|
});
|
||||||
|
|
||||||
|
return graphRequest(`${pageId}/feed`, { method: "POST", params });
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- Publicacion: Instagram (cuenta profesional) ----------
|
// ---------- Publicacion: Instagram (cuenta profesional) ----------
|
||||||
|
|
||||||
export async function publishInstagramPost({ igBusinessId, imageUrl, videoUrl, caption }) {
|
export async function publishInstagramPost({ igBusinessId, imageUrl, videoUrl, caption, media }) {
|
||||||
|
if (media && media.length >= 2) {
|
||||||
|
return publishInstagramCarousel({ igBusinessId, caption, media });
|
||||||
|
}
|
||||||
if (!imageUrl && !videoUrl) {
|
if (!imageUrl && !videoUrl) {
|
||||||
throw new Error("Instagram requiere imageUrl o videoUrl (contenido accesible por URL publica)");
|
throw new Error("Instagram requiere imageUrl o videoUrl (contenido accesible por URL publica)");
|
||||||
}
|
}
|
||||||
@@ -73,6 +105,40 @@ export async function publishInstagramPost({ igBusinessId, imageUrl, videoUrl, c
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IG carrusel: cada elemento es un child container (is_carousel_item=true),
|
||||||
|
// se agrupan en un container padre de tipo CAROUSEL y se publica ese.
|
||||||
|
async function publishInstagramCarousel({ igBusinessId, caption, media }) {
|
||||||
|
if (media.length < 2 || media.length > 10) {
|
||||||
|
throw new Error("Un carrusel de Instagram admite entre 2 y 10 elementos");
|
||||||
|
}
|
||||||
|
|
||||||
|
const childIds = [];
|
||||||
|
for (const item of media) {
|
||||||
|
const isVideo = item.type === "video";
|
||||||
|
const child = await graphRequest(`${igBusinessId}/media`, {
|
||||||
|
method: "POST",
|
||||||
|
params: isVideo
|
||||||
|
? { video_url: item.url, is_carousel_item: "true" }
|
||||||
|
: { image_url: item.url, is_carousel_item: "true" },
|
||||||
|
});
|
||||||
|
if (isVideo) {
|
||||||
|
await waitUntilContainerReady(child.id);
|
||||||
|
}
|
||||||
|
childIds.push(child.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parent = await graphRequest(`${igBusinessId}/media`, {
|
||||||
|
method: "POST",
|
||||||
|
params: { media_type: "CAROUSEL", children: childIds.join(","), caption: caption || "" },
|
||||||
|
});
|
||||||
|
await waitUntilContainerReady(parent.id);
|
||||||
|
|
||||||
|
return graphRequest(`${igBusinessId}/media_publish`, {
|
||||||
|
method: "POST",
|
||||||
|
params: { creation_id: parent.id },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function waitUntilContainerReady(containerId, { timeoutMs = 60000, intervalMs = 3000 } = {}) {
|
async function waitUntilContainerReady(containerId, { timeoutMs = 60000, intervalMs = 3000 } = {}) {
|
||||||
const deadline = Date.now() + timeoutMs;
|
const deadline = Date.now() + timeoutMs;
|
||||||
while (Date.now() < deadline) {
|
while (Date.now() < deadline) {
|
||||||
|
|||||||
+8
-1
@@ -3,6 +3,7 @@ import express from "express";
|
|||||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||||
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
||||||
import { registerTools } from "./tools.js";
|
import { registerTools } from "./tools.js";
|
||||||
|
import { mediaDir } from "./media.js";
|
||||||
|
|
||||||
function buildServer() {
|
function buildServer() {
|
||||||
const server = new McpServer({ name: "socialmcp", version: "1.0.0" });
|
const server = new McpServer({ name: "socialmcp", version: "1.0.0" });
|
||||||
@@ -11,7 +12,13 @@ function buildServer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(express.json());
|
|
||||||
|
const uploadLimitMb = (Number(process.env.MAX_UPLOAD_MB) || 50) + 5;
|
||||||
|
app.use(express.json({ limit: `${uploadLimitMb}mb` }));
|
||||||
|
|
||||||
|
// Sirve los archivos subidos via upload_media en /media/<archivo>, publicos
|
||||||
|
// para que Meta pueda leerlos al publicar.
|
||||||
|
app.use("/media", express.static(mediaDir()));
|
||||||
|
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
const requiredToken = process.env.MCP_AUTH_TOKEN;
|
const requiredToken = process.env.MCP_AUTH_TOKEN;
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import path from "path";
|
||||||
|
import crypto from "crypto";
|
||||||
|
|
||||||
|
const MIME_EXT = {
|
||||||
|
"image/jpeg": "jpg",
|
||||||
|
"image/png": "png",
|
||||||
|
"image/webp": "webp",
|
||||||
|
"image/gif": "gif",
|
||||||
|
"video/mp4": "mp4",
|
||||||
|
"video/quicktime": "mov",
|
||||||
|
};
|
||||||
|
|
||||||
|
export function mediaDir() {
|
||||||
|
const dir = process.env.MEDIA_DIR || path.join(process.cwd(), "media");
|
||||||
|
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
function extensionFor(mimeType, filename) {
|
||||||
|
const fromName = path.extname(filename || "").replace(".", "").toLowerCase();
|
||||||
|
if (/^[a-z0-9]{2,5}$/.test(fromName)) return fromName;
|
||||||
|
return MIME_EXT[mimeType] || "bin";
|
||||||
|
}
|
||||||
|
|
||||||
|
function publicBaseUrl() {
|
||||||
|
const base = process.env.MEDIA_BASE_URL;
|
||||||
|
if (!base) throw new Error("Falta MEDIA_BASE_URL en el entorno (.env)");
|
||||||
|
return base.replace(/\/+$/, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function saveMedia({ filename, mimeType, dataBase64 }) {
|
||||||
|
if (!mimeType || !(mimeType.startsWith("image/") || mimeType.startsWith("video/"))) {
|
||||||
|
throw new Error("mimeType debe ser image/* o video/*");
|
||||||
|
}
|
||||||
|
if (!dataBase64) throw new Error("Falta dataBase64");
|
||||||
|
|
||||||
|
const buffer = Buffer.from(dataBase64, "base64");
|
||||||
|
const maxBytes = (Number(process.env.MAX_UPLOAD_MB) || 50) * 1024 * 1024;
|
||||||
|
if (buffer.length === 0) throw new Error("El contenido decodificado esta vacio");
|
||||||
|
if (buffer.length > maxBytes) {
|
||||||
|
throw new Error(`El archivo supera el limite de ${maxBytes / (1024 * 1024)}MB`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ext = extensionFor(mimeType, filename);
|
||||||
|
const id = crypto.randomUUID();
|
||||||
|
const storedName = `${id}.${ext}`;
|
||||||
|
fs.writeFileSync(path.join(mediaDir(), storedName), buffer);
|
||||||
|
|
||||||
|
cleanupOldMedia();
|
||||||
|
|
||||||
|
return {
|
||||||
|
url: `${publicBaseUrl()}/media/${storedName}`,
|
||||||
|
storedName,
|
||||||
|
sizeBytes: buffer.length,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanupOldMedia() {
|
||||||
|
const retentionDays = Number(process.env.MEDIA_RETENTION_DAYS) || 7;
|
||||||
|
const cutoff = Date.now() - retentionDays * 24 * 60 * 60 * 1000;
|
||||||
|
const dir = mediaDir();
|
||||||
|
for (const name of fs.readdirSync(dir)) {
|
||||||
|
const filePath = path.join(dir, name);
|
||||||
|
try {
|
||||||
|
const stat = fs.statSync(filePath);
|
||||||
|
if (stat.mtimeMs < cutoff) fs.unlinkSync(filePath);
|
||||||
|
} catch {
|
||||||
|
// ignora errores de limpieza puntuales, no deben afectar la subida actual
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+45
-3
@@ -9,6 +9,7 @@ import {
|
|||||||
replyFacebookComment,
|
replyFacebookComment,
|
||||||
replyInstagramComment,
|
replyInstagramComment,
|
||||||
} from "./graph.js";
|
} from "./graph.js";
|
||||||
|
import { saveMedia } from "./media.js";
|
||||||
|
|
||||||
function text(payload) {
|
function text(payload) {
|
||||||
return { content: [{ type: "text", text: JSON.stringify(payload, null, 2) }] };
|
return { content: [{ type: "text", text: JSON.stringify(payload, null, 2) }] };
|
||||||
@@ -37,16 +38,31 @@ export function registerTools(server) {
|
|||||||
title: "Publicar en Facebook/Instagram",
|
title: "Publicar en Facebook/Instagram",
|
||||||
description:
|
description:
|
||||||
"Publica contenido propio en la Facebook Page y/o cuenta profesional de Instagram configuradas. " +
|
"Publica contenido propio en la Facebook Page y/o cuenta profesional de Instagram configuradas. " +
|
||||||
"Instagram exige imageUrl o videoUrl (no admite publicaciones de solo texto).",
|
"Instagram exige imageUrl/videoUrl o media (no admite publicaciones de solo texto). " +
|
||||||
|
"Para publicar un carrusel (varias imagenes/videos deslizables en un mismo post) usa `media` " +
|
||||||
|
"con 2 a 10 elementos en vez de imageUrl/videoUrl.",
|
||||||
inputSchema: {
|
inputSchema: {
|
||||||
platform: z.enum(["facebook", "instagram", "both"]),
|
platform: z.enum(["facebook", "instagram", "both"]),
|
||||||
message: z.string().describe("Texto del post o caption"),
|
message: z.string().describe("Texto del post o caption"),
|
||||||
imageUrl: z.string().url().optional().describe("URL publica de una imagen"),
|
imageUrl: z.string().url().optional().describe("URL publica de una imagen (post de un solo elemento)"),
|
||||||
videoUrl: z.string().url().optional().describe("URL publica de un video (IG lo publica como Reel)"),
|
videoUrl: z.string().url().optional().describe("URL publica de un video (IG lo publica como Reel)"),
|
||||||
linkUrl: z.string().url().optional().describe("Solo Facebook: enlace a incluir en un post de texto"),
|
linkUrl: z.string().url().optional().describe("Solo Facebook: enlace a incluir en un post de texto"),
|
||||||
|
media: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
|
url: z.string().url(),
|
||||||
|
type: z.enum(["image", "video"]).default("image"),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.min(2)
|
||||||
|
.max(10)
|
||||||
|
.optional()
|
||||||
|
.describe(
|
||||||
|
"Lista de 2 a 10 elementos para publicar un carrusel. Sustituye a imageUrl/videoUrl."
|
||||||
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
async ({ platform, message, imageUrl, videoUrl, linkUrl }) => {
|
async ({ platform, message, imageUrl, videoUrl, linkUrl, media }) => {
|
||||||
try {
|
try {
|
||||||
const results = {};
|
const results = {};
|
||||||
if (platform === "facebook" || platform === "both") {
|
if (platform === "facebook" || platform === "both") {
|
||||||
@@ -56,6 +72,7 @@ export function registerTools(server) {
|
|||||||
imageUrl,
|
imageUrl,
|
||||||
videoUrl,
|
videoUrl,
|
||||||
linkUrl,
|
linkUrl,
|
||||||
|
media,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (platform === "instagram" || platform === "both") {
|
if (platform === "instagram" || platform === "both") {
|
||||||
@@ -64,6 +81,7 @@ export function registerTools(server) {
|
|||||||
imageUrl,
|
imageUrl,
|
||||||
videoUrl,
|
videoUrl,
|
||||||
caption: message,
|
caption: message,
|
||||||
|
media,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return text(results);
|
return text(results);
|
||||||
@@ -73,6 +91,30 @@ export function registerTools(server) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
server.registerTool(
|
||||||
|
"upload_media",
|
||||||
|
{
|
||||||
|
title: "Subir imagen/video local",
|
||||||
|
description:
|
||||||
|
"Sube un archivo local (imagen o video) codificado en base64 y lo publica en una URL publica " +
|
||||||
|
"servida por este mismo servidor, para poder usarla luego en publish_post (imageUrl/videoUrl/media). " +
|
||||||
|
"Los archivos se borran automaticamente tras unos dias (retencion configurable).",
|
||||||
|
inputSchema: {
|
||||||
|
filename: z.string().describe("Nombre de archivo original, ej. foto.jpg"),
|
||||||
|
mimeType: z.string().describe("Tipo MIME, ej. image/jpeg o video/mp4"),
|
||||||
|
dataBase64: z.string().describe("Contenido del archivo codificado en base64"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
async ({ filename, mimeType, dataBase64 }) => {
|
||||||
|
try {
|
||||||
|
const result = saveMedia({ filename, mimeType, dataBase64 });
|
||||||
|
return text(result);
|
||||||
|
} catch (err) {
|
||||||
|
return errorText(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
server.registerTool(
|
server.registerTool(
|
||||||
"list_posts",
|
"list_posts",
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user