This commit is contained in:
bipproduction
2025-11-20 10:42:53 +08:00
parent 148ad40712
commit ecbde4cbe3
2 changed files with 15 additions and 26 deletions

View File

@@ -300,7 +300,7 @@ async function handleMCPRequest(
// Converter MCP content yang valid // Converter MCP content yang valid
function convertToMcpContent(data: any) { function convertToMcpContent(data: any) {
// Jika string → text // String → text
if (typeof data === "string") { if (typeof data === "string") {
return { return {
type: "text", type: "text",
@@ -308,8 +308,8 @@ async function handleMCPRequest(
}; };
} }
// Jika kirim tipe khusus image (base64) // Image (dengan __mcp_type)
if (data?.__mcp_type === "image" && typeof data.base64 === "string") { if (data?.__mcp_type === "image" && data.base64) {
return { return {
type: "image", type: "image",
data: data.base64, data: data.base64,
@@ -317,8 +317,8 @@ async function handleMCPRequest(
}; };
} }
// Jika audio // Audio
if (data?.__mcp_type === "audio" && typeof data.base64 === "string") { if (data?.__mcp_type === "audio" && data.base64) {
return { return {
type: "audio", type: "audio",
data: data.base64, data: data.base64,
@@ -326,31 +326,20 @@ async function handleMCPRequest(
}; };
} }
// Jika resource link // Semua lainnya → text (untuk mencegah error Zod union)
if (data?.__mcp_type === "resource_link" && data.uri) {
return {
type: "resource_link",
name: data.name || "resource",
uri: data.uri,
};
}
// Jika object biasa → jadikan resource (wrap arrays into object)
if (typeof data === "object") {
const resource = Array.isArray(data) ? { items: data } : data;
return {
type: "resource",
resource,
};
}
// fallback → text stringified
return { return {
type: "text", type: "text",
text: JSON.stringify(data, null, 2), text: (() => {
try {
return JSON.stringify(data, null, 2);
} catch {
return String(data);
}
})(),
}; };
} }
try { try {
const baseUrl = credentials?.baseUrl; const baseUrl = credentials?.baseUrl;
const token = credentials?.token; const token = credentials?.token;

View File

@@ -1,6 +1,6 @@
{ {
"name": "n8n-nodes-openapi-mcp-server", "name": "n8n-nodes-openapi-mcp-server",
"version": "1.1.27", "version": "1.1.28",
"keywords": [ "keywords": [
"n8n", "n8n",
"n8n-nodes" "n8n-nodes"