Skip to content

MCP server fails to connect: Schema is missing a method literal #9

@irresi

Description

@irresi

Problem

The MCP server (src/mcp/server.ts) fails to establish a connection with MCP clients. When running gbrain serve, the server outputs Schema is missing a method literal and the connection drops immediately.

Root cause: setRequestHandler is called with raw string literals ('tools/list', 'tools/call') cast via as any, instead of the Zod schema objects exported by @modelcontextprotocol/sdk. In SDK v1.29.0, this causes the handler registration to fail silently and the connection to close.

Reproduction

# Start the MCP server
DATABASE_URL=<your_url> bun run src/cli.ts serve
# Output: "Schema is missing a method literal"

# Attempt to list tools via mcporter
mcporter list gbrain --schema
# Output: "Tools: <timed out> / Connection closed"

Fix

Replace string literals with the SDK's typed request schemas:

+ import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';

- server.setRequestHandler('tools/list' as any, async () => ({
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({

- server.setRequestHandler('tools/call' as any, async (request: any) => {
+ server.setRequestHandler(CallToolRequestSchema, async (request: any) => {

After the fix, mcporter list gbrain --schema returns all 30 tools and mcporter call gbrain.get_stats works correctly.

Additional findings

While testing the MCP server fix, I also found two openclaw integration issues:

  1. openclaw plugins install failspackage.json is missing openclaw.extensions, so the CLI treats it as an invalid native plugin instead of recognizing openclaw.plugin.json. The Plugin Bundles docs say openclaw.plugin.json should be detected as native, but the installer checks package.json first and errors out. This may require either adding openclaw.extensions to package.json or filing upstream with openclaw.

  2. test/e2e/skills.test.ts uses openclaw -p — This flag no longer exists in openclaw 2026.4.x. The current equivalent is openclaw agent --local -m. This change is not backward compatible with older openclaw versions, so the minimum supported version needs to be decided (noting package.json already declares "pluginApi": ">=2026.4.0").

Environment

  • gbrain v0.3.0
  • @modelcontextprotocol/sdk v1.29.0
  • openclaw 2026.4.9
  • macOS, Bun 1.3.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions