Add MCP client support to ds4-agent#573
Open
aovestdipaperino wants to merge 2 commits into
Open
Conversation
Load stdio MCP servers from a .mcp.json file (or --mcp-config FILE), advertise their tools to the model as mcp__<server>__<tool> alongside the native DSML tools, and dispatch calls over newline-delimited JSON-RPC. Servers that fail to spawn or handshake are dropped with a warning instead of aborting the agent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A per-server primaryTools list in .mcp.json controls prompt cost: listed tools keep their full schema in the system prompt, the rest appear as one-line directory entries, and the model fetches a full schema on first use via the new mcp_describe tool. With tokensave's 81 tools this shrinks the MCP prompt block by ~71%. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Model Context Protocol (MCP) client support to
ds4-agent, so external stdio MCP servers can extend the agent with new tools without touching C code..mcp.jsonfile (same shape Claude Code uses:mcpServers: {name: {command, args, env}}), read from the working directory or via the new--mcp-config FILEflag. MCP is fully optional: a missing file is silently fine, a malformed one warns and is skipped, and a server that fails to spawn or handshake is dropped with a warning instead of aborting the agent.ds4_agent.c. Tool calls stay synchronous like every other agent tool; requests carry a 30s whole-exchange deadline so a misbehaving server cannot hang a turn.mcp__<server>__<tool>and rendered into the system prompt in the same function-call JSON shape as the native tools. Dispatch plugs intoagent_execute_tool_call, and results flatten to plain text like every other tool.primaryToolslist splits tools into primary (full schema in the prompt) and directory entries (one line each); the model fetches directory schemas on demand with the new nativemcp_describetool. With tokensave's 81 tools this shrinks the MCP prompt block by ~71%.Testing
makestays warning-clean;ds4_agent_testgrows 13 unit tests covering the JSON round-trip, config parsing (including rejection of__in server names), DSML-args→JSON-RPC conversion, primary/directory prompt rendering, andmcp_describeresolution.tools/list,tools/callround trip) and against a real 81-tool server, including the on-demand schema path.🤖 Generated with Claude Code