feat(mcp): add server instructions to initialize response#389
Conversation
|
Premature — closing to test in fork first, will reopen when ready. |
|
Hi @badigit — any updates on this? I noticed it's been sitting closed for a few weeks since the "test in fork first" note. Bumping it because we just hit the exact problem this fixes: a Claude Code session connected to an mcpproxy deployment had no way to discover which upstreams were available, because the initialize response carries no The branch still merges cleanly against Thanks! |
|
Reopened and refreshed 👋 Thanks for the nudge, @Dumbris — confirmed the gap is still open (no top-level Pushed one follow-up commit so the default text is routing-mode-aware (Spec 031), instead of assuming
Original |
Add configurable Instructions field to Config that is returned in the MCP initialize response via WithInstructions. When not set, a built-in default explains the retrieve_tools → call_tool workflow and warns against using search_servers for existing tool discovery. This helps AI agents understand how to correctly use the proxy without requiring per-client system prompt configuration.
Refresh defaultInstructions so the connect-time guidance covers all three Spec 031 routing modes, not just retrieve_tools: - retrieve_tools -> call_tool_read/write/destructive via the call_with field - code_execution for single-step multi-tool orchestration - direct mode tools listed as server__tool, called by name Keeps the original search_servers / upstream_servers guidance. Extends the key-terms test to assert code_execution and server__tool are covered.
…ument config config.Config.Instructions is surfaced in the OpenAPI spec via GetConfigResponse, so the generated oas/swagger.yaml and oas/docs.go must be regenerated (make swagger) and committed — enforced by the "Verify OpenAPI Artifacts" CI gate. Also documents the field in docs/configuration.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
a34214d to
2318444
Compare
|
Thank you for this contribution, @badigit! 🙏 This is exactly the kind of quality-of-life improvement that helps every agent connecting to mcpproxy — surfacing I've pushed two small maintainer follow-ups on top of your commits so we could land it:
Your original commits are preserved with full authorship. I also rebuilt the branch onto current Merging now. We'd love to see more from you — there's a good first-issue list if you're looking for the next one. 🚀 |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Dumbris
left a comment
There was a problem hiding this comment.
Approved. Small, well-scoped change: adds a configurable instructions field surfaced in the MCP initialize response with a routing-mode-aware default. Verified locally: go build ./... clean, instructions unit tests pass, OpenAPI artifacts regenerated (Verify OpenAPI Artifacts green), and config field documented. Thanks again @badigit!
Adds a 'MCP server instructions' accordion to Settings → Advanced with an editable textarea bound to the top-level `instructions` config key via the key-driven SettingsSection pattern (getPath/buildPartial). - New `textarea` control type in the settings field catalogue + SettingField. - Built-in default shown as the placeholder, fetched live from /api/v1/status `default_instructions` (never hardcoded in the frontend); degrades gracefully when an older core doesn't expose it. - Empty-means-default: clearing the box (incl. whitespace-only) persists "", which the backend maps back to the built-in default. - vitest unit tests for the textarea control + field catalogue; docs row note. Related #389 Related MCP-2175
Adds a 'MCP server instructions' accordion to Settings → Advanced with an editable textarea bound to the top-level `instructions` config key via the key-driven SettingsSection pattern (getPath/buildPartial). - New `textarea` control type in the settings field catalogue + SettingField. - Built-in default shown as the placeholder, fetched live from /api/v1/status `default_instructions` (never hardcoded in the frontend); degrades gracefully when an older core doesn't expose it. - Empty-means-default: clearing the box (incl. whitespace-only) persists "", which the backend maps back to the built-in default. - vitest unit tests for the textarea control + field catalogue; docs row note. Related #389 Related MCP-2175
Summary
instructionsfield to top-levelConfigthat is returned in the MCP initialize response viaWithInstructionsretrieve_tools→call_tool_*workflow and warns against usingsearch_serversfor existing tool discoveryProblem
When an MCP client connects to mcpproxy-go, the initialize response contains no
instructionsfield. Agents receive no guidance on how to use the proxy, leading to confusion betweenretrieve_tools(search existing upstream tools) andsearch_servers(discover NEW servers from external registries). We observed agents going to external registries to "find" Bitrix24 tools that were already connected as upstreams.Changes
internal/config/config.go: AddInstructions stringfield toConfiginternal/server/mcp.go: AdddefaultInstructionsconst,resolveInstructions()helper, pass tomcpserver.WithInstructions()internal/server/mcp_instructions_test.go: Tests for default/custom instructionsTest plan
go build ./...passesgo test ./internal/server/... -run Instructions -v— all passinstructionsfield