Fix/mcp tool discovery flow#95
Merged
simongdavies merged 4 commits intohyperlight-dev:mainfrom Apr 29, 2026
Merged
Conversation
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines HyperAgent’s MCP (Model Context Protocol) integration to make external tool usage more discoverable and safer, by adding focused tool/schema discovery (mcp_tool_info), improving MCP tool result normalization, and introducing a dedicated execution profile for MCP network latency.
Changes:
- Added
mcp_tool_info(and enhancedmcp_server_infofiltering) to support focused schema discovery before writing handler code. - Standardized MCP tool-call results into an
{ ok, data, text, raw, meta, error, truncated }envelope and updated guidance/tests accordingly. - Introduced the
mcp-networkprofile (longer wall timeout, no plugins) and updated CLI/docs/tests to include it.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/profiles.test.ts | Updates expectations for the new mcp-network profile and profile count/stacking behavior. |
| tests/mcp.test.ts | Adds tests for MCP tool selection/read-only inference helpers and tool result normalization. |
| tests/command-suggestions.test.ts | Adds coverage for extracting markdown-bold suggested commands. |
| src/agent/tool-gating.ts | Allows the new mcp_tool_info tool through the tool gate. |
| src/agent/system-message.ts | Updates system guidance for MCP “handler-only” workflow and tool discovery. |
| src/agent/profiles.ts | Adds the mcp-network resource profile (wall-time bump without plugins). |
| src/agent/mcp/tool-utils.ts | New helper utilities for tool lookup, selection, scoring, and read-only inference. |
| src/agent/mcp/plugin-adapter.ts | Uses read-only inference for the write-safety gate; updates MCP hints/declarations to async. |
| src/agent/mcp/client-manager.ts | Introduces the MCP result envelope and normalization logic for tool calls. |
| src/agent/index.ts | Enhances mcp_server_info, adds mcp_tool_info, and wires it into the session tool list. |
| src/agent/command-suggestions.ts | Improves command extraction robustness (bold markdown + cleaning). |
| src/agent/cli-parser.ts | Documents the new mcp-network profile in CLI help text. |
| skills/mcp-services/SKILL.md | Updates the recommended MCP workflow to use mcp_tool_info, handler-only execution, and mcp-network. |
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
Signed-off-by: Simon Davies <simongdavies@users.noreply.github.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.
This pull request introduces significant improvements to the MCP (Model Context Protocol) integration, focusing on safer, more discoverable, and auditable external tool usage. The changes refine the workflow for accessing MCP tools, add a new
mcp_tool_infotool for focused schema lookup, and enhance command extraction and error handling throughout the agent. Documentation and code now guide users to always discover tool schemas before usage, and handler code receives more robust, structured results.Key changes:
MCP Tool Usage Workflow & Documentation
SKILL.mdto require using the newmcp_tool_infotool for focused tool/schema discovery before writing handler code, discouraging direct tool invocation from LLM tools and emphasizing handler-based execution for auditability. The documentation now details best practices, error handling, and response envelopes for MCP tool calls.New and Enhanced MCP Tools
mcp_tool_infotool to the agent, allowing users to query for specific tool schemas on a server using tool names or natural language queries, returning only relevant schemas and TypeScript declarations. This tool is now included in the allowed tools and recommended workflow.mcp_server_infoto support filtering tools by name, query, or limit, and to recommend usingmcp_tool_infofor focused schema lookup.Improved Tool Call Results and Error Handling
ok,data,text,raw,meta,error,truncated), ensuring handler code can reliably check for errors and parse results.Command Extraction Robustness
CLI and Miscellaneous Updates
mcp-networkprofile to the CLI options and documentation, clarifying its use for extending wall-clock time during MCP handler execution.These changes together make MCP tool usage more robust, discoverable, and secure, while improving the developer and user experience.