You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
my app’s backend is written in nodejs and I want to develop a chatbot in my application powered by Pinecone Assistant’s MCP server.
I’ve found the javascript code for uploading data to the Pinecone Assistant ( Upload files - Pinecone Docs )
import { MultiServerMCPClient } from "@langchain/mcp-adapters";
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
// Create client and connect to server
const client = new MultiServerMCPClient({
// Global tool configuration options
// Whether to throw on errors if a tool fails to load (optional, default: true)
throwOnLoadError: true,
// Whether to prefix tool names with the server name (optional, default: true)
prefixToolNameWithServerName: true,
// Optional additional prefix for tool names (optional, default: "mcp")
additionalToolNamePrefix: "mcp",
// Server configuration
mcpServers: {
pinecone_assistant: {
url: "pinecone-mcp-server-url",
transport: "sse",
headers: {
Authorization:
"Bearer pinecone-api-key",
},
useNodeEventSource: true,
reconnect: {
enabled: true,
maxAttempts: 5,
delayMs: 2000,
},
},
},
});
const tools = await client.getTools();
// Create an OpenAI model
const model = new ChatOpenAI({
modelName: "gpt-4o-mini",
temperature: 0,
apiKey:"openai-api-key"
});
// Create the React agent
const agent = createReactAgent({
llm: model,
tools,
});
// Run the agent
try {
const aiResponse = await agent.invoke({
messages: [{ role: "user", content: "hello" }],
});
console.log(aiResponse);
} catch (error) {
console.error("Error during agent execution:", error);
// Tools throw ToolException for tool-specific errors
if (error.name === "ToolException") {
console.error("Tool execution failed:", error.message);
}
}
await client.close();
I'm getting an error when running this agent.
PS C:\Users\gaura\Desktop\Chatbot> node agent.js
(node:22864) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
(Use node --trace-deprecation … to show where the warning was created)
file:///C:/Users/gaura/Desktop/Chatbot/node_modules/@langchain/mcp-adapters/dist/client.js:434
throw new MCPClientError(Failed to create SSE transport for server “${serverName}”: ${error}, serverName);
^
MCPClientError: Failed to create SSE transport for server “pinecone_assistant”: MCPClientError: Failed to connect to SSE server “pinecone_assistant”: Error: SSE error: Non-200 status code (401)
at MultiServerMCPClient._initializeSSEConnection (file:///C:/Users/gaura/Desktop/Chatbot/node_modules/@langchain/mcp-adapters/dist/client.js:434:19)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async MultiServerMCPClient.initializeConnections (file:///C:/Users/gaura/Desktop/Chatbot/node_modules/@langchain/mcp-adapters/dist/client.js:297:17)
at async MultiServerMCPClient.getTools (file:///C:/Users/gaura/Desktop/Chatbot/node_modules/@langchain/mcp-adapters/dist/client.js:314:9)
at async file:///C:/Users/gaura/Desktop/Chatbot/agent.js:33:15 {
serverName: ‘pinecone_assistant’
}
Node.js v22.11.0
@gauravmindzk I think this may have been fixed in v0.4.3, but can you please test with @langchain/mcp-adapters@0.4.4 (releasing now) and report back? I'm not sure if pincone supports streamable HTTP yet, but if it does, please try with that (likely requires removing the transport: "sse" line from your config, and changing the url path to /mcp instead of /sse). It Streamable HTTP has built-in support for passing headers, whereas it had to be sort of hacked in for SSE.
I'll leave this open for now, but please report back what you find and close if things are working for you. Thanks!
my app’s backend is written in nodejs and I want to develop a chatbot in my application powered by Pinecone Assistant’s MCP server.
I’ve found the javascript code for uploading data to the Pinecone Assistant ( Upload files - Pinecone Docs )
I want a similar code for ( Use an Assistant MCP server - Pinecone Docs ) this .
Below is my agent’s code using Python:
I want its equivalent in javascript .
I came across Langchain’s github repo GitHub - langchain-ai/langchainjs-mcp-adapters: Adapters for integrating Model Context Protocol (MCP) tools with LangChain.js applications, supporting both stdio and SSE transports.
and tried setting up the code .
I'm getting an error when running this agent.
Package Versions:
The text was updated successfully, but these errors were encountered: