feat(mcp): advertise native args object on call_tool_* variants#379
Merged
feat(mcp): advertise native args object on call_tool_* variants#379
Conversation
Adds an `args` object parameter alongside `args_json` on call_tool_read,
call_tool_write, and call_tool_destructive. The handler already accepted
`args` as a fallback, but the schema did not advertise it — so LLM clients
always produced pre-serialized JSON strings, costing ~350 tokens per call
and producing frequent escaping bugs (see luutuankiet/mcp-proxy-shim for
context).
Clients can now send arguments as a native JSON object:
{ "name": "github:get_user", "args": { "username": "octocat" } }
instead of:
{ "name": "github:get_user", "args_json": "{\"username\":\"octocat\"}" }
`args_json` remains advertised and takes precedence when both are provided,
so existing clients continue to work unchanged.
The tool definitions for the default `/mcp` and `/mcp/call` routes were
duplicated across mcp.go and mcp_routing.go; factored them into a shared
`buildCallToolVariantTool(variant)` helper to keep the schema in sync.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Deploying mcpproxy-docs with
|
| Latest commit: |
1a6e45c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://934ce287.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-args-object-call-tool.mcpproxy-docs.pages.dev |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 24285806964 --repo smart-mcp-proxy/mcpproxy-go
|
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 a native
argsobject parameter alongside the legacyargs_jsonstring oncall_tool_read,call_tool_write, andcall_tool_destructive.Clients can now send arguments as a native JSON object:
{ "name": "github:get_user", "args": { "username": "octocat" } }instead of a pre-serialized string:
{ "name": "github:get_user", "args_json": "{\"username\":\"octocat\"}" }Motivation
Spotted via luutuankiet/mcp-proxy-shim — a client-side shim that transforms
args_jsonintoargsto eliminate escaping overhead. Shim benchmarks: ~350 tokens saved per call, frequent escaping bugs eliminated. This brings the fix server-side.The handler at
internal/server/mcp.go:1289already accepted anargsobject as a fallback — only the advertised schema was missing it, so LLM clients never discovered the native path.Changes
WithObject("args", ...)to the tool schemas (3 variants × 2 routes).mcp.go/mcp_routing.gointo a sharedbuildCallToolVariantTool(variant)helper.args_jsonremains advertised and wins when both are provided — fully backward-compatible.Tests
New
internal/server/mcp_call_tool_args_test.go:TestCallToolVariantSchemaAdvertisesArgsObject— schema contractTestHandleCallToolVariantAcceptsArgsObject— runtime extraction pathTestHandleCallToolVariantArgsJSONWinsWhenBothProvided— precedence / backward compatTest plan
go test ./internal/server/ -run 'TestCallTool|TestHandleCall|TestArgsJson|TestMCPProxyServer_'passesgo test ./internal/runtime/...passesgo vet ./internal/server/...cleantools/liston/mcpand/mcp/call— both routes showargs(object) +args_json(string) on all three variantstools/callwith nativeargsobject reaches upstream dispatch (errors on missing server, not arg parsing)🤖 Generated with Claude Code