-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
area:apiarea:mcpbugSomething isn't workingSomething isn't workinghas reproHas detailed reproduction stepsHas detailed reproduction steps
Description
Environment
- Platform (select one):
- Anthropic API
- AWS Bedrock
- Google Vertex AI
- Other: Claude Code SDK
- Claude CLI version: 1.0.96
- Operating System: macOS 15.1
- Terminal: Terminal App
Bug Description
The new SDK MCP server type does not work with basic string prompts.
Running with DEBUG=true, I see the following error:
[ERROR] MCP server "test" Failed to connect SDK MCP server: Error: Stream closed
Steps to Reproduce
Below is a basic sample:
import { createSdkMcpServer, query, tool } from "@anthropic-ai/claude-code";
import { z } from "zod";
const mcp = createSdkMcpServer({
name: "test",
tools: [
tool(
"add",
"Add two numbers",
{
a: z.number(),
b: z.number(),
},
async ({ a, b }) => {
return {
content: [
{
type: "text",
text: `${a + b}`,
},
],
};
}
),
],
});
for await (const message of query({
//prompt: generateMessages(),
prompt: "Use the tool to add 1 and 2 and return the result.",
options: {
mcpServers: {
test: mcp,
},
allowedTools: ["mcp__test__add"],
},
})) {
console.log(JSON.stringify(message));
}Expected Behavior
Prompt should run with successful connection and access to the SDK MCP server.
Actual Behavior
Claude CLI process exits with an error.
selenehyun, tariqkb, ShuangLiu1992, tom-n-terra, codylund and 10 moreadamk-au and Gerauddasp
Metadata
Metadata
Assignees
Labels
area:apiarea:mcpbugSomething isn't workingSomething isn't workinghas reproHas detailed reproduction stepsHas detailed reproduction steps