Skip to content

fix(memory): rename MCP tool names to comply with strict client naming regex#59

Merged
codeaholicguy merged 1 commit intocodeaholicguy:mainfrom
nnhhoang:fix/mcp-tool-name-regex-compliance
Apr 17, 2026
Merged

fix(memory): rename MCP tool names to comply with strict client naming regex#59
codeaholicguy merged 1 commit intocodeaholicguy:mainfrom
nnhhoang:fix/mcp-tool-name-regex-compliance

Conversation

@nnhhoang
Copy link
Copy Markdown
Contributor

@nnhhoang nnhhoang commented Apr 16, 2026

Summary

Fixes #40. MCP clients like Antigravity enforce the tool-name pattern ^[a-zA-Z0-9_-]{1,64}$, which rejects the existing memory.* tool names due to the dot separator.

This PR:

  • Renames tools to underscore: memory_storeKnowledge, memory_updateKnowledge, memory_searchKnowledge
  • Keeps backward-compat: the CallTool dispatcher still accepts the deprecated dotted names so agents on older init templates/prompts continue working. Aliases can be removed in next major.
  • Exports TOOLS and adds a unit test asserting every registered tool name satisfies the MCP naming regex — guards against future regressions.

Files changed

  • packages/memory/src/server.ts - rename + dispatcher aliases + export TOOLS
  • packages/memory/tests/unit/server.test.ts - new regex compliance test
  • packages/memory/README.md - updated examples
  • Per-agent remember command templates (Claude, Cursor, Codex, Gemini, Antigravity, GitHub Copilot, generic)
  • Historical docs/ai/* feature docs intentionally left unchanged

Test plan

  • nx run-many -t test passes - 393 tests across 4 packages
  • New unit test: 3 registered tool names pass ^[a-zA-Z0-9_-]{1,64}$
  • Lint clean (0 errors)
  • End-to-end verification with @modelcontextprotocol/sdk client against built server - all 10 checks pass (ListTools regex compliance, new-name dispatch, backward-compat dispatch, unknown-name negative control). Output posted as a comment on this PR.

…g regex

MCP clients like Antigravity enforce the tool-name pattern
^[a-zA-Z0-9_-]{1,64}$, which rejects the existing memory.storeKnowledge,
memory.updateKnowledge, and memory.searchKnowledge tool names because of
the dot separator. Rename to memory_storeKnowledge, memory_updateKnowledge,
memory_searchKnowledge so the server is loadable across all MCP clients.

To keep existing users on older init templates from breaking, the
CallTool dispatcher also accepts the deprecated dotted names as
backward-compat aliases. The aliases can be removed in the next major.

Exports the TOOLS array and adds a unit test that asserts every
registered tool name satisfies the MCP naming regex, guarding against
future regressions when new tools are added.

Updates README examples and all per-agent remember command templates
(Claude, Cursor, Codex, Gemini, Antigravity, GitHub Copilot, generic
agent workflows) to reference the new names. Historical design docs
under docs/ai/ are intentionally left unchanged as frozen records.

Fixes codeaholicguy#40
@nnhhoang
Copy link
Copy Markdown
Contributor Author

nnhhoang commented Apr 16, 2026

Manual verification via a spec-compliant MCP client

I ran a small MCP client built with the official @modelcontextprotocol/sdk against the memory server from this branch. MCP is an open protocol — any spec-compliant client (Antigravity included, based on the error regex ^[a-zA-Z0-9_-]{1,64}$ from the issue) sees the same ListTools output the server emits, so this reproduces the failure path at the protocol layer.

The script exercises four things:

  1. ListTools — what Antigravity scans on load, against the exact regex ^[a-zA-Z0-9_-]{1,64}$ from its error message
  2. CallTool with the new underscore names — must reach the handler (ValidationError is expected since args are empty)
  3. CallTool with the deprecated dotted names — must still dispatch (backward-compat alias)
  4. CallTool with a garbage name — negative control; must return UNKNOWN_TOOL

Output

=== 1. ListTools — what Antigravity scans on load ===
  PASS  memory_storeKnowledge
  PASS  memory_updateKnowledge
  PASS  memory_searchKnowledge

=== 2. CallTool with NEW underscore names (empty args -> expect ValidationError, NOT UNKNOWN_TOOL) ===
  PASS  memory_storeKnowledge          -> error code: VALIDATION_ERROR
  PASS  memory_updateKnowledge         -> error code: VALIDATION_ERROR
  PASS  memory_searchKnowledge         -> error code: VALIDATION_ERROR

=== 3. CallTool with DEPRECATED dotted names (backward-compat alias) ===
  PASS  memory.storeKnowledge          -> error code: VALIDATION_ERROR
  PASS  memory.updateKnowledge         -> error code: VALIDATION_ERROR
  PASS  memory.searchKnowledge         -> error code: VALIDATION_ERROR

=== 4. CallTool with GARBAGE name (expect UNKNOWN_TOOL — negative control) ===
  PASS  memory_nonsenseTool         -> error code: UNKNOWN_TOOL

ALL CHECKS PASSED

The VALIDATION_ERROR responses in sections 2 and 3 are the evidence that the dispatcher routed the call to the correct handler (handlers validate before touching the DB). UNKNOWN_TOOL in section 4 is the negative control — proves the dispatcher isn't blindly accepting every name.

Reproducible — the script (~60 lines of Node ESM) can be shared on request.

@nnhhoang
Copy link
Copy Markdown
Contributor Author

nnhhoang commented Apr 16, 2026

Confirmed in a real Antigravity install

Also loaded the built server into Antigravity locally via ~/.gemini/antigravity/mcp_config.json:

{
  "mcpServers": {
    "memory-local-test": {
      "command": "node",
      "args": ["<path-to>/ai-devkit/packages/memory/dist/index.js"]
    }
  }
}

Antigravity's "Manage MCP servers" panel shows:

  • Server memory-local-test: Enabled, 3 / 3 tools loaded
  • All three tools (memory_storeKnowledge, memory_updateKnowledge, memory_searchKnowledge) have their description rendered and toggles on
  • No red tool name … violates ^[a-zA-Z0-9_-]{1,64}$ error banners — the exact failure mode from the original issue is gone

Screenshot attached below.
Ảnh màn hình 2026-04-17 lúc 04 51 43

@codeaholicguy
Copy link
Copy Markdown
Owner

@nnhhoang thanks for the contribution, this LGTM.

@codeaholicguy codeaholicguy merged commit dc83711 into codeaholicguy:main Apr 17, 2026
7 checks passed
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.

Antigravity cannot use MCP Memory

2 participants