fix(mcp): proxy all 51 tools to server, not just 7 hardcoded IMPLEMENTED_TOOLS (closes #234)#238
fix(mcp): proxy all 51 tools to server, not just 7 hardcoded IMPLEMENTED_TOOLS (closes #234)#238cl0ckt0wer wants to merge 2 commits intorohitg00:mainfrom
Conversation
…_TOOLS (closes rohitg00#234) - tools/list now fetches from GET /agentmemory/mcp/tools in proxy mode, returning all 51 tools instead of filtering to 7 - handleToolCall proxies ALL tools to POST /agentmemory/mcp/call in proxy mode, skipping local IMPLEMENTED_TOOLS validation - Removed handleProxy() — the generic /agentmemory/mcp/call endpoint replaces per-tool REST endpoint mapping - In local mode (no server), IMPLEMENTED_TOOLS filter and validate() are preserved for InMemoryKV compatibility - Added 4 tests for proxy mode forwarding, payload shape, and local-mode behavior
|
@cl0ckt0wer is attempting to deploy a commit to the rohitg00's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR unifies MCP proxy dispatch: tool calls resolve a handle and, in proxy mode, are POSTed to /agentmemory/mcp/call (with array-shaped content returned directly); proxy failures invalidate the handle and fall back to local execution. tools/list delegates to /agentmemory/mcp/tools with local fallback. Tests expanded accordingly. ChangesMCP Proxy Tool Dispatch Unification
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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/mcp/standalone.ts`:
- Around line 259-268: The proxy catch block currently only logs the proxy error
and always falls through to validate() causing an "Unknown tool" error for tools
that aren't locally implemented; change the behavior so that inside the catch
you check whether toolName is in IMPLEMENTED_TOOLS (or equivalent set), and if
it is not, rethrow or throw a new Error that includes the original proxy error
message (preserving err) so callers see the connectivity/server error; if the
tool is implemented locally, keep calling invalidateHandle() and fall back to
validate(toolName, args) and handleLocal(validated, kvInstance).
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3094ecd2-c5f7-468b-b9e1-827c6370ec89
📒 Files selected for processing (3)
src/mcp/standalone.tstest/mcp-standalone-proxy.test.tstest/mcp-standalone.test.ts
…lling through to validate
|
Fixed the CodeRabbit review finding in Problem: The proxy catch block only logged the error and always fell through to Fix: Inside the catch block, check
Added a test in |
|
Reviewed — this is a clean fix for a real regression. The hardcoded Looks good:
Approving for merge. Holding the actual merge button until @rohitg00 confirms — but no blockers from my side. (Worth flagging in the CHANGELOG under Fixed: "MCP standalone proxy now exposes all 51 tools when |
|
Thanks @cl0ckt0wer — root cause analysis here was exactly right, and your tests for proxy/auth/fallback shaped the landed fix. Superseded by #270 (merged in v0.9.6, 2026-05-10), which implements the same approach: probe Closing as superseded — not because the work wasn't valuable. Appreciate the deep diagnostic on the original issue. |
Summary
Fixes #234 —
agentmemory mcp --tools allnow returns all 51 tools instead of silently filtering to 7.Root cause
src/mcp/standalone.tshad a hardcodedIMPLEMENTED_TOOLSset of 7 tool names. Bothtools/listandvalidate()applied this filter unconditionally, even when the server was reachable in proxy mode.getVisibleTools()correctly returned all 51 tools whenAGENTMEMORY_TOOLS=allwas set, but the filter then cut them down to 7.Changes
src/mcp/standalone.tstools/listnow proxy-aware: When in proxy mode, fetches all tools fromGET /agentmemory/mcp/tools(server returns unfiltered 51). Falls back to the local filtered list if the server is unreachable or returns an unexpected shape.handleToolCallproxies ALL tools: Proxy resolution now happens before validation. In proxy mode, any tool call is forwarded toPOST /agentmemory/mcp/callwith{ name, arguments }payload — the server'smcp::tools::callendpoint already has handlers for all 51 tools.Removed
handleProxy(): The 7-tool switch that mapped each tool to a different REST endpoint is replaced by the generic/agentmemory/mcp/callendpoint. This eliminated ~54 lines of per-tool proxy code.Local mode preserved: In local mode (no server),
IMPLEMENTED_TOOLSfilter andvalidate()are preserved — theInMemoryKVgenuinely only supports 7 operations.test/mcp-standalone.test.tsresolveHandleto return local mode for all local tests (prevents server-probe side effects)test/mcp-standalone-proxy.test.ts/agentmemory/mcp/callendpointcontentarg passes through)/agentmemory/mcp/callVerification
Non-IMPLEMENTED_TOOLS calls now succeed:
Test results
Summary by CodeRabbit
New Features
Bug Fixes
Tests