Skip to content

MCP server name over 64 chars: all its tools are silently dropped, and the server still shows connected #53400

Closed

Description

@nkoynov

Description

If an MCP server's name is longer than 64 characters (after _ normalization), none of its tools get registered. GET /api/mcp still says connected, and the only sign is one ERROR log line per tool. namespaceError in tool.ts requires each namespace segment to match ^[A-Za-z0-9_-]{1,64}$, but McpTool.namespace (tool/mcp.ts:16) only replaces characters and never shortens the name. #51207 raised tool names to 128 chars, but the namespace limit is still 64.

We hit this through T3 Code, which names its per-thread server t3-code-<threadId> (96+ chars), so the agent gets none of T3's tools.

Suggested fix: shorten long names in McpTool.namespace, for example the first 55 chars + _ + an 8-char hash of the full name. Permission names built from it (McpTool.name) would have to use the same short form. Or at least show the rejection in /api/mcp.

Plugins

none

OpenCode version

2.0.22. The code is the same in 2.0.23 and on v2 @ ef07075.

Steps to reproduce

  1. Project opencode.json, with a 65-char server name and any stdio MCP server (we used a 30-line Python one):
    {"mcp":{"servers":{"srv_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":{"type":"local","command":["python3","mcp_server.py"]}}}}
  2. Run opencode serve, then GET /api/mcp?directory=<project>. The server is listed as connected.
  3. opencode.log then shows, for every tool:
    level=ERROR message="Skipping invalid tool registration" name=get_vault_code namespace=srv_aaaa…aaa error="Invalid tool namespace: \"srv_aaaa…aaa\""
    
    None of the server's tools reach the model. With a short name, the same server works.

Screenshot and/or share link

n/a

Operating System

NixOS 26.11 (Linux 6.18)

Terminal

n/a (opencode serve)

Activity

  1. github-actions commented on Oct 5, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

  2. rekram1-node commented on Oct 6, 2026

    @rekram1-node
    Collaborator

    it names every server w/ 96+ chars? Won't most apis reject that entirely...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions