Skip to content

fix: MCP standalone shim proxies full server tool set (#234)#270

Merged
rohitg00 merged 1 commit intomainfrom
fix/234-mcp-shim-proxy-all-tools
May 10, 2026
Merged

fix: MCP standalone shim proxies full server tool set (#234)#270
rohitg00 merged 1 commit intomainfrom
fix/234-mcp-shim-proxy-all-tools

Conversation

@rohitg00
Copy link
Copy Markdown
Owner

@rohitg00 rohitg00 commented May 10, 2026

Summary

  • agentmemory mcp capped non-Claude clients (OpenCode, Cursor, Gemini CLI, Cline, …) at the local 7-tool IMPLEMENTED_TOOLS set even when an agentmemory server was reachable. With AGENTMEMORY_TOOLS=all on the server the user expected 51 tools.
  • The shim now delegates tools/list to GET /agentmemory/mcp/tools and forwards any non-essential tool to POST /agentmemory/mcp/call when in proxy mode.
  • Local InMemoryKV fallback is unchanged — it still implements only the 7 essential tools, with a clearer error for unknown tools when no server is reachable.

Live e2e (server: AGENTMEMORY_TOOLS=all)

Pre-fix:

shim → tools/list  → 4 tools (default), 7 (TOOLS=all)
shim → memory_lesson_save → "Unknown tool"

Post-fix:

shim → tools/list  → 51 tools
shim → memory_lesson_save → lesson lsn_xxx created

Driver script used: stdio JSON-RPC initialize → tools/list → tools/call.

Tests

  • test/mcp-standalone-proxy.test.ts — new cases covering proxy-forward of non-essential tools and the no-server failure mode.
  • Full suite: 856 passing.

Closes #234.

Summary by CodeRabbit

  • New Features

    • Improved tool discovery and support for non-Claude MCP clients through server-side proxying.
    • Unknown tools are now forwarded to the remote server instead of being rejected locally.
    • Enhanced error handling for unreachable servers.
  • Tests

    • Added test coverage for remote tool proxy functionality and failure scenarios.

Review Change Stack

`agentmemory mcp` capped non-Claude clients (OpenCode, Cursor, Gemini
CLI, Cline, …) at the local 7-tool `IMPLEMENTED_TOOLS` set even when an
agentmemory server was reachable. With `AGENTMEMORY_TOOLS=all` on the
server the user expected 51 tools — the shim filtered the response down
to whatever subset overlapped its hardcoded set (4 by default, 7 with
the env var on).

When a server is reachable, the shim now:

- Delegates `tools/list` to GET `/agentmemory/mcp/tools` and returns
  the server's full advertised set verbatim.
- Forwards any tool not in the local `IMPLEMENTED_TOOLS` set to
  POST `/agentmemory/mcp/call` (the server validates per tool).

The local `InMemoryKV` fallback path is unchanged — it still implements
only the 7 essential tools, and unknown tools throw a clear error
pointing to `AGENTMEMORY_URL` when no server is reachable.

Verified live end-to-end:

- Pre-fix: shim → tools/list returns 4 tools (default) / 7 (TOOLS=all);
  `memory_lesson_save` → "Unknown tool".
- Post-fix: shim → tools/list returns 51 tools when the server runs
  with TOOLS=all; `memory_lesson_save` → lesson created end-to-end via
  the shim's stdio JSON-RPC interface.

Two regression tests added covering the proxy-forward path and the
no-server failure mode.

Closes #234.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agentmemory Ready Ready Preview, Comment May 10, 2026 6:03pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0d499717-8d97-424d-943d-106e07969237

📥 Commits

Reviewing files that changed from the base of the PR and between 0322da8 and 683b043.

📒 Files selected for processing (2)
  • src/mcp/standalone.ts
  • test/mcp-standalone-proxy.test.ts

📝 Walkthrough

Walkthrough

The pull request extends the MCP standalone server to support tool proxying and remote tool discovery. When running in proxy mode, unknown tools are forwarded to /agentmemory/mcp/call, and the tool list is fetched from /agentmemory/mcp/tools, enabling non-Claude clients to access the full 51-tool surface beyond the 7 locally-implemented tools.

Changes

MCP Proxy Tool Discovery and Calling

Layer / File(s) Summary
Generic Proxy Forwarding
src/mcp/standalone.ts
New handleProxyGeneric function forwards arbitrary tool calls to the remote /agentmemory/mcp/call endpoint and returns remote MCP content or serialized text response.
Tool Call Routing
src/mcp/standalone.ts
handleToolCall now attempts remote proxy execution for unknown tools when in proxy mode, including error logging, handle invalidation, and rethrow on failure.
Remote Tool List Discovery
src/mcp/standalone.ts
tools/list handler fetches remote tools from /agentmemory/mcp/tools in proxy mode; falls back to local IMPLEMENTED_TOOLS on fetch failure.
Proxy Integration Tests
test/mcp-standalone-proxy.test.ts
Two new Vitest cases verify successful forwarding of memory_lesson_save tool and error handling when the remote server is unreachable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 A proxy path for tools untold,
Beyond the seven we once could hold—
Now fifty-one shine bright and clear,
For every client far and near! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: MCP standalone shim proxies full server tool set (#234)' clearly and concisely summarizes the main change: enabling the MCP standalone shim to proxy the full server tool set instead of limiting to 7 tools.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from #234: proxies tools/list to GET /agentmemory/mcp/tools in proxy mode, forwards unknown tool calls to POST /agentmemory/mcp/call, maintains local fallback for non-proxy mode, and includes test coverage for proxy and failure scenarios.
Out of Scope Changes check ✅ Passed All changes in src/mcp/standalone.ts and test/mcp-standalone-proxy.test.ts are directly aligned with the issue #234 objectives of proxying the full server tool set and handling server unreachability.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/234-mcp-shim-proxy-all-tools

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rohitg00 rohitg00 merged commit 6e011e5 into main May 10, 2026
5 checks passed
@rohitg00 rohitg00 mentioned this pull request May 10, 2026
rohitg00 added a commit that referenced this pull request May 10, 2026
Three reliability fixes from #269/#270/#271:

- search/recall surfaces saved memories (closes #265)
- MCP shim proxies full server tool set (closes #234)
- session/subagent hooks no longer block startup (closes #221)

Also fixes packages/mcp version drift — was stuck at 0.9.4 through v0.9.5,
now lockstepped with main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP shim: --tools all returns only 7 tools due to IMPLEMENTED_TOOLS hardcode

1 participant