Skip to content

fix: Ignore wait_for_previous argument to support Gemini MCP clients#322

Merged
bensig merged 1 commit intoMemPalace:developfrom
dbshadow:fix-gemini-mcp
Apr 12, 2026
Merged

fix: Ignore wait_for_previous argument to support Gemini MCP clients#322
bensig merged 1 commit intoMemPalace:developfrom
dbshadow:fix-gemini-mcp

Conversation

@dbshadow
Copy link
Copy Markdown
Contributor

@dbshadow dbshadow commented Apr 9, 2026

Describe the bug

When using Mempalace with the Gemini CLI MCP client, the client automatically injects an undocumented wait_for_previous argument into the tool execution request. This causes a TypeError: unexpected keyword argument in mcp_server.py and crashes the tool execution.

Solution

Added a safe .pop("wait_for_previous", None) before passing tool_args to the handler. This safely drops the non-standard argument and restores compatibility with Gemini clients without affecting other standard clients like Claude Desktop or Cursor.

Copy link
Copy Markdown

@web3guru888 web3guru888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix — .pop() is the right primitive for this. Gemini shouldn't be injecting undeclared arguments, but servers should be robust to it. ✅

One thought for a follow-up (not blocking this PR): right now this protects against wait_for_previous specifically. If Gemini or another MCP client starts injecting additional non-standard arguments in the future, we'd need another .pop() line.

A more generic guard would be to filter against the declared inputSchema properties:

known_keys = set(schema_props.keys())
tool_args = {k: v for k, v in tool_args.items() if k in known_keys}

This goes right after the existing type-coercion loop (which already iterates schema_props), so it's a natural fit. Trade-off is that it silently drops any unknown arg — could mask real typos — but since we already validate required args via the schema, the risk is low.

Not suggesting this should block the PR — the targeted .pop() is fine for now and the fix is needed. Just flagging for future hardening.

Perseusxrltd added a commit to Perseusxrltd/mnemion that referenced this pull request Apr 9, 2026
- pyproject.toml: widen chromadb to <2.0 for Python 3.14 compat (MemPalace#302)
- config.py + miner/convo_miner/mcp_server: add hnsw:space=cosine so
  similarity = 1 - distance stays in [0,1] instead of negative L2 (MemPalace#304)
- searcher.py + layers.py: guard against ChromaDB 1.x empty-outer query
  results (IndexError on fresh collections) (MemPalace#305)
- mcp_server.py: redirect stdout→stderr at import to protect JSON-RPC
  wire from chromadb/posthog chatter (MemPalace#306)
- mcp_server.py: replace 10k-limited col.get with paginating
  _iter_all_metadatas helper; stop swallowing errors silently (MemPalace#307)
- mcp_server.py: drop undocumented wait_for_previous arg injected by
  Gemini MCP clients (MemPalace#322)
- searcher.py + hybrid_searcher.py + mcp_server.py: add min_similarity
  threshold filter so callers get a clean "no results" signal (MemPalace#350)
- entity_detector.py: add CODE_KEYWORDS blocklist (~80 terms) to stop
  Rust types / React / framework names being detected as entities (MemPalace#349)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@bensig bensig changed the base branch from main to develop April 11, 2026 22:22
Copy link
Copy Markdown
Collaborator

@bensig bensig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review + security audit clean. One-liner Gemini compat fix.

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.

3 participants