Skip to content

Implement domain-namespaced tool registry for MCP server#1789

Merged
fderuiter merged 1 commit into
mainfrom
jules/domain-namespaced-tools-js1-ad387dc1-91fd-4cd1-ade1-d6ec9a5123ef
Jul 23, 2026
Merged

Implement domain-namespaced tool registry for MCP server#1789
fderuiter merged 1 commit into
mainfrom
jules/domain-namespaced-tools-js1-ad387dc1-91fd-4cd1-ade1-d6ec9a5123ef

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

Why This Change Is Necessary

Previously, the MCP server registered all prompts, workflows, and skills into a single flat list. In enterprise AI applications, this lack of segregation poses severe operational and safety risks:

  1. Lack of Isolation: High-stakes clinical tools were mixed with creative or lifestyle assets, making it difficult for client-side agents to safely restrict tool availability.
  2. Name Collisions: If two different domains had tools with the same base filename (e.g., a data_validation workflow in both the business and clinical domains), the server would experience collisions and registration overwrites.

By introducing domain-namespacing (e.g., clinical__breast_cancer_trial and business__data_validation), we enable enterprise AI architects to dynamically route and isolate tools using simple prefix filtering (e.g., matching only clinical__* for medical assistants).


Key Decisions & Technical Implementation

1. Dynamic Domain & Category Extraction

  • We now derive the category/domain of a tool dynamically using metadata tags, YAML metadata fields, or parent folder fallbacks.
  • The extracted domain name is normalized to be lowercase and fully alphanumeric (with underscores as word separators).

2. Domain Prefixing and Sanitization

  • Tools are registered with the format: [domain]__[tool_name].
  • We adjusted the server's name sanitization logic to preserve the double-underscore (__) delimiter, ensuring that standard sanitization does not collapse this critical namespace boundary.

3. MCP Protocol-Compliant Truncation

  • To prevent exceeding the MCP protocol's character limits, any generated namespaced tool name that exceeds 64 characters is truncated to 55 characters and appended with a unique, deterministic 8-character hash (totaling 63 characters). This prevents namespace collision while remaining fully compliant with MCP limits.

4. Execution Pipeline Resolution

  • We integrated the namespace mapping directly into get_tool_name_mcp during the discovery phase.
  • Incoming tool executions with fully-namespaced names are resolved seamlessly back to their original workspace files and underlying assets.

Verification and Testing

  • Unit Tests Updated & Added:
    • Updated existing test suite assertions in tests/test_utils.py to match namespaced behavior.
    • Added test_namespaced_tool_registry_and_truncation to verify domain-namespacing, long name truncation, unique hash generation, name collision avoidance across domains, and explicit domain override metadata.
  • Results: All unit tests successfully passed with 100% coverage for registry namespaces.

@google-labs-jules
google-labs-jules Bot requested a review from fderuiter as a code owner July 23, 2026 14:33
@fderuiter
fderuiter merged commit 77b195d into main Jul 23, 2026
1 check failed
@fderuiter
fderuiter deleted the jules/domain-namespaced-tools-js1-ad387dc1-91fd-4cd1-ade1-d6ec9a5123ef branch July 23, 2026 14:48
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.

1 participant