Skip to main content
createMcpToolset connects to a Model Context Protocol server over stdio, lists its tools once, and returns an AI SDK tools record: the inbound MCP path, turning any MCP server into an agent tool provider with no per-service wrapper. 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

Call close() in a finally block when the workflow process owns the connection: the MCP client and spawned server process stay open until it resolves.

API

command, args, env, and cwd pass through to the MCP SDK stdio transport; client identity defaults to clientName: "smithers-mcp-toolset", 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 calls tools/list once and wraps each selected MCP tool with AI SDK dynamicTool; invoking one calls MCP tools/call with the original tool name and the model-provided arguments. Response handling is simple:
  • Successful calls return structuredContent when the server provides it, otherwise 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.
Schema handling follows the MCP server’s advertised inputSchema, falling back to an empty object JSON schema if a server omits it.

CLI Agents

CLI agents consume MCP through their native configuration surfaces, not through createMcpToolset. Claude Code, Kimi, and Amp expose MCP config flags; Codex reads MCP servers from ~/.codex/config.toml or codex mcp add. Use createMcpToolset when building an SDK-agent workflow with AnthropicAgent, OpenAIAgent, HermesAgent, or a raw AI SDK tool-loop agent.

See Also