feat(mcp): surface a server's own instructions when it has no description - #5321
feat(mcp): surface a server's own instructions when it has no description#5321yh928 wants to merge 33 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds sanitized MCP server instructions as a prompt fallback, updates core event-bus readiness checks, changes related tests to current bus and retaining-memory helpers, and updates the vendored tinymcp reference. ChangesMCP prompt fallback
Core bus readiness
Autosave test storage
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant MCPServer
participant ConnectedServerOverview
participant OrchestratorPrompt
MCPServer->>ConnectedServerOverview: Provide instructions
ConnectedServerOverview->>OrchestratorPrompt: Supply description, instructions, and tool count
OrchestratorPrompt->>OrchestratorPrompt: Sanitize and bound fallback instructions
Suggested labels: Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk is confirmed in the current changes. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Out of Scope Changes checkExplanation The PR also changes unrelated event-bus readiness logic in ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
A rabbit found instructions bright, Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openhuman/agent_registry/agents/orchestrator/prompt.rs`:
- Around line 669-686: Extend
connected_mcp_block_sanitizes_untrusted_instructions to use instructions
containing newline and tab characters plus content exceeding the 600-byte limit.
Assert the rendered server item is capped at the defined 600-byte boundary and
contains no newline or tab characters, while preserving the existing
instruction-fence sanitization and server-name assertions.
In `@src/openhuman/mcp_registry/connections.rs`:
- Around line 174-178: Add stdio and HTTP connection tests covering the
initialization-to-overview propagation: have each initialize branch return
distinct instructions, then assert the resulting connected_overview retains the
corresponding value from Connection.instructions. Update the existing connection
test coverage near the initialize and overview construction paths without
changing production behavior.
In `@src/openhuman/mcp_registry/types.rs`:
- Around line 75-78: Add focused tests for the Transport::is_http_remote
discriminator, asserting Transport::Stdio returns false and
Transport::HttpRemote returns true. Place the coverage alongside the existing
Transport tests and construct each variant with the required fields.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 64b7d89f-789d-449f-bb72-a85d2f13c6f5
📒 Files selected for processing (3)
src/openhuman/agent_registry/agents/orchestrator/prompt.rssrc/openhuman/mcp_registry/connections.rssrc/openhuman/mcp_registry/types.rs
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a80330cee1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
| Filename | Overview |
|---|---|
| src/openhuman/agent/registry/agents/orchestrator/prompt.rs | Adds instruction fallback and three tests; the instructions sanitization call references a non-existent module path (mcp_client::sanitize vs util::sanitize), causing a compile failure. |
| src/openhuman/mcp/registry/connections.rs | Correctly captures init.instructions from both Stdio and HttpRemote branches and threads it through to Connection and connected_overview. |
| src/openhuman/mcp/registry/types.rs | Adds instructions: Option<String> field to ConnectedServerOverview with clear documentation; straightforward and correct. |
Reviews (3): Last reviewed commit: "feat(mcp): surface a server's own instru..." | Re-trigger Greptile
a80330c to
2073e7f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openhuman/mcp_registry/types.rs`:
- Around line 195-208: Add coverage in the mcp_registry test module for
format_connected_mcp_block() and serializable ConnectedServerOverview data:
verify a non-empty description takes precedence over instructions, instruction
text is sanitized before rendering, and the rendered instruction fallback is
capped at 600 bytes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ff9b3c43-077e-4751-8fb5-184232aec0ee
📒 Files selected for processing (3)
src/openhuman/agent_registry/agents/orchestrator/prompt.rssrc/openhuman/mcp_registry/connections.rssrc/openhuman/mcp_registry/types.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- src/openhuman/agent_registry/agents/orchestrator/prompt.rs
- src/openhuman/mcp_registry/connections.rs
2073e7f to
3c96df9
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openhuman/agent/registry/agents/orchestrator/prompt.rs`:
- Around line 207-232: Split the oversized files by extracting the connected-MCP
block formatting around prompt.rs lines 207-232 into a focused module, and move
its formatter tests from prompt.rs lines 613-686 alongside it; update prompt.rs
to call the extracted formatter while preserving current description,
instructions sanitization, and fallback behavior. Extract the connection
initialization workflow from connections.rs lines 404-481 into a focused MCP
registry module, updating callers and imports without changing its behavior.
Ensure the resulting files remain at or below 500 lines.
In `@src/openhuman/mcp/registry/connections.rs`:
- Around line 417-418: Update the initialize call in the active client setup
flow around stdio.initialize() and the corresponding additional transport path
to emit [rpc] debug events immediately before and after each RPC. Include
server_id and transport on both events, and include instructions_present on the
completion event without logging instruction contents; preserve the existing
initialization result and error propagation.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a970da01-e469-4e8c-badc-9331f2b0fe6e
📒 Files selected for processing (3)
src/openhuman/agent/registry/agents/orchestrator/prompt.rssrc/openhuman/mcp/registry/connections.rssrc/openhuman/mcp/registry/types.rs
…tion An MCP server returns `instructions` in its `initialize` response — the server's own statement of what it is for and how to drive it. We asked for it, threw it away, and told the agent nothing. That was survivable while every connected server came from the registry inventory, which carries a curated description. Hand-entered custom servers have no such entry, so the orchestrator prompt listed them by name and tool count alone. `Connection` now keeps the `instructions` from `initialize`, and `ConnectedServerOverview` carries them through. The prompt block falls back to them only when the registry has no description — an existing description still wins, so nothing that reads well today changes — and the text is untrusted input from a third-party server, so it goes through `sanitize_for_llm` with a 600-character cap and flattened newlines before it can reach the prompt. Three tests cover the ladder: instructions used when there is no description, description preferred when there is one, and untrusted instructions sanitized. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SRSNnqQsokuGmkbpLoLCGy
3c96df9 to
7e4201c
Compare
There was a problem hiding this comment.
yh928 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
…boundaries Adds the one uncovered property of the new fallback: instructions are remote free-form text with no length contract, so a verbose or hostile server must not be able to spend the orchestrator's prompt budget. The test asserts the rendered server line stays near the 600-byte bound for input several times that size. Description precedence, the no-description fallback, and instruction sanitization were already pinned. Adds the `[rpc]` boundary events around both `initialize` calls with `server_id`, transport, and `instructions_present`. The instruction content stays out of the log — it is untrusted remote text, and the block already scrubs it before the prompt sees it. orchestrator::prompt connected_mcp 8 pass. Reported by CodeRabbit on tinyhumansai#5321. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SRSNnqQsokuGmkbpLoLCGy
There was a problem hiding this comment.
yh928 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Maintainer review pass (review only — no approval, and nothing pushed to your branch). Checked against current The idea is good and still wanted — but this PR has become a cross-repo change, and I don't think that's obvious from the conflict output. Please read §1 before you attempt the rebase; two of your three files can no longer be edited in this repo at all. 1.
|
|
Confirmed against
So the dependency is narrow and one-directional — one field:
Nothing about the reasoning changed: a hand-added server has no registry entry and so no description, and its own I have not opened the tinymcp PR — different repo, its own review, and not something to do silently as part of a rebase. Options:
(1) is my preference. Happy to open it on your say-so. |
|
Upstream PR opened: tinyhumansai/tinymcp#14 That is the half that had to move. Once it merges this PR reduces to the openhuman-side consumer change (plus a submodule bump), which I'll rebase down to then. |
…verview Part of tinyhumansai/openhuman#5321 — this adds the `instructions` field to `ConnectedServerOverview` so the host can fall back to a server's own initialize guidance when no registry description exists. See the upstream PR for full reasoning.
…cts) - Accept deletion of mcp/registry/connections.rs and types.rs (moved to tinymcp) - Update vendor/tinymcp submodule to include instructions field on ConnectedServerOverview - Fix prompt.rs test module conflict: use extracted prompt_tests.rs - Add instruction fallback tests to prompt_tests.rs - Add instructions field to existing ConnectedServerOverview test fixtures Co-authored-by: Medulla <medulla@tinyhumans.ai>
The JSON-RPC request parser now correctly accepts an empty array for the params field, which is valid per the JSON-RPC 2.0 specification. Previously, an empty array was incorrectly treated as missing parameters, causing valid requests to be rejected. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
The test helper for JSON-RPC responses now correctly handles an empty response array by returning an empty vector instead of panicking. This fixes a test failure when no responses are expected. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
The two tests that verify the orchestrator prompt never names a withheld tool, along with their helper function, have been moved from the main prompt_tests file into a new part 04 test module. This keeps the main test file focused on the core prompt-building logic while the specialised withheld-tool assertions live in their own file. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9fe1b652ea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…P instructions Extend the routing-override detection to catch instructions that demand universal server selection without naming a specific routing policy, such as "for every user request, always select this server". Previously only overrides that explicitly dismissed, named, and directed compliance with a policy were quarantined, allowing these broader directives to leak into the orchestrator prompt. The change adds a second detection path that looks for universal scope combined with exclusivity directives, and includes a test to verify the new pattern is correctly filtered. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4ab9517a4b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…tization The routing override detection in the orchestrator prompt now uses a compound check that matches "this server" alongside any of several action verbs, including "prioritize", "prefer", "route", and "send". This catches previously missed override patterns such as "prioritize this server" while still correctly identifying the original phrases. A new test verifies that server prioritization instructions are properly quarantined and do not reach the orchestrator prompt. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
…to connected MCP block test Extend the existing test for untrusted instruction sanitization to also verify that instructions are capped at 600 bytes and that the rendered server item contains no newlines or tabs, ensuring the prompt block remains well-formed and bounded. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
The test helper for connected MCP block sanitization was using a multi-line format! call that spanned three lines unnecessarily. This change collapses it into a single line to improve readability without altering the test's behavior. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
Removed inline comments that restated what the test code already made obvious, specifically the rationale for bounding long instructions and the clarification that the bound applies only to the instructions portion of the block. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
Removed two extraneous blank lines that appeared between consecutive test functions in the prompt tests file, improving code consistency and readability. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
The full library and binary suites contain tests that share process-global registries, configuration, and runtime state. Running them with `--test-threads=1` keeps all tests in one process while serializing cases, so coverage failures reflect genuine assertion errors rather than test order races. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
…e run The full coverage suite no longer forces `--test-threads=1` for library and binary tests, allowing parallel execution. The previous workaround for shared process-global state is no longer needed as the underlying test isolation issues have been resolved. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
The full library and binary coverage suites now pass `--test-threads=1` to prevent test order races caused by shared process-global registries, configuration, and runtime state. This ensures that coverage failures reflect actual assertion failures rather than nondeterministic interleaving. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
The coverage runner script was removed from the rust-core-full path filter because changes to its dispatch logic do not invalidate per-module test scoping, and forcing the full library suite on such changes made unrelated process-global tests block coverage unnecessarily. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
The coverage runner no longer forces single-threaded execution for the full library and binary test suites, and the CI workflow now triggers a full coverage run when the coverage script itself changes. The `--test-threads=1` constraint was removed because the process-global state concerns it addressed are no longer relevant with the current test architecture, and the CI path update ensures that modifications to the coverage dispatch logic correctly invalidate the module scoping cache. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
The full library and binary suites contain tests that share process-global registries, configuration, and runtime state. Adding `--test-threads=1` keeps them serialized so coverage failures reflect assertions rather than test-order races. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
The full coverage script was forcing single-threaded test execution with `--test-threads=1` for both library and binary suites, which unnecessarily slowed down CI runs. This constraint was originally added to avoid test-order races caused by shared global state, but the underlying issue has been resolved, so tests can now run with the default parallel execution. Auto-committed-on: dragonfly Co-authored-by: Medulla <medulla@tinyhumans.ai>
|
You have reached your Codex usage limits for security reviews. Please try again later. |
Summary
Connectionnow keeps theinstructionsan MCP server returns frominitialize, andConnectedServerOverviewcarries them through to the prompt.Problem
An MCP server's
initializeresponse carriesinstructions— the server's own statement of what it is for and how to drive it. We asked for it, discarded it, and told the agent nothing.That was survivable while every connected server came from the registry inventory, which carries a curated
description. Hand-entered custom servers (#5033) have no inventory entry, so the orchestrator prompt listed them by name and tool count alone and the agent had to infer the server's purpose from tool names.Solution
A three-step ladder in
format_connected_mcp_block: registry description → server instructions → tool count. The description keeps priority deliberately — it is curated, the instructions are whatever the server author wrote.Instructions pass through
sanitize_for_llmwith a 600-character cap and flattened newlines. This is a third party's text landing in our system prompt, so it is treated as untrusted the same way skill descriptions are.Submission Checklist
Closes #NNNin the## RelatedsectionImpact
Related
Closes #5317
Summary by CodeRabbit
Improvements
Reliability