createMcpToolset connects to a Model Context Protocol server over stdio, lists its tools once, and returns an AI SDK-compatible tools record for an SDK agent. This is the inbound MCP integration path: use any MCP server as an agent tool provider without writing one wrapper per external service.
For the opposite direction, where an MCP-aware client drives Smithers workflows, see MCP Server.
Import
createMcpToolset is intentionally a deep import from @smithers-orchestrator/agents/mcp/createMcpToolset; it is not re-exported from the top-level smithers-orchestrator facade.
Quick Start
close() in a finally block when the workflow process owns the connection. The MCP client and spawned server process stay open until close() resolves.
API
command, args, env, and cwd are passed to the MCP SDK stdio transport. The Smithers client identity defaults to clientName: "smithers-mcp-toolset" and clientVersion: "0.0.0".
Tool Curation
include and exclude match the original MCP server tool names before namePrefix is applied. If both match a tool, exclude wins. toolNames contains the final names after filtering and prefixing.
Runtime Behavior
On connect, Smithers callstools/list once and wraps every selected MCP tool with AI SDK dynamicTool. When an agent invokes one of those tools, the wrapper calls MCP tools/call with the original server tool name and the model-provided arguments.
Response handling is intentionally simple:
- Successful calls return
structuredContentwhen the server provides it. - Otherwise successful calls return the joined text content blocks.
- MCP tool errors return
{ error: true, message, status: "failed" }so the agent can inspect and recover inside its tool loop.
inputSchema. If a server omits it, Smithers uses an empty object JSON schema.
CLI Agents
CLI agents consume MCP through their native configuration surfaces, not throughcreateMcpToolset. Claude Code, Kimi, and Amp expose MCP config flags; Codex reads MCP servers from ~/.codex/config.toml or codex mcp add.
Use createMcpToolset when you are building an SDK-agent workflow with AnthropicAgent, OpenAIAgent, HermesAgent, or a raw AI SDK tool-loop agent.