Skip to content

mcp-serve: Expose Tools as MCP

The mcp-serve subcommand turns Wayland Core into an MCP server. Instead of acting only as a client that connects to external servers, the engine exposes its own tool registry over MCP so other clients (Claude Desktop, an MCP CLI, or your own host) can discover what tools are available via tools/list.

The default transport is stdio, which is what MCP clients spawn directly:

Terminal window
wayland-core mcp-serve

For a networked setup, use SSE. It binds to loopback on port 9876 by default:

Terminal window
wayland-core mcp-serve --transport sse --bind 127.0.0.1:9876

The --bind address applies only to the SSE transport and is ignored for stdio. Keep the bind on loopback unless you have a specific reason to expose it on a broader interface.

ArgumentDefaultNotes
--transportstdiostdio or sse.
--bind127.0.0.1:9876SSE only. Ignored for stdio.

The stdio transport runs until end of input. The SSE transport runs until it is aborted.

When a client connects and sends tools/list, the server replies with all tools registered in the engine’s live ToolRegistry. Deferred tools are included in the list because the deferred flag is an engine-side LLM-prompt-budget optimization that has no meaning over the MCP wire.

The initialize response identifies the server as wcore-mcp and negotiates protocol version 2024-11-05.

All tools/call requests pass through a PolicyCheck gate before reaching the (not yet wired) dispatch layer. The production gate wraps wcore_agent::policy_gate::PolicyGate and returns POLICY_DENIED (-32001) for any tool not covered by an active grant. This gating is in place now even though the dispatch layer is not yet functional.

A client that spawns stdio servers points at the binary and the subcommand. For example, a Claude Desktop config entry:

{
"mcpServers": {
"wayland-core": {
"command": "wayland-core",
"args": ["mcp-serve"]
}
}
}

For SSE, start the server first, then point the client at the bind address. The client performs the standard MCP handshake and can call tools/list to inspect the tool catalog.

CodeNameWhen
-32600INVALID_REQUESTjsonrpc field is not "2.0".
-32601METHOD_NOT_FOUNDUnknown method or unknown tool name in tools/call.
-32602INVALID_PARAMStools/call params are missing or name is absent.
-32001POLICY_DENIEDPolicy gate blocked the tool.
-32002NOT_IMPLEMENTEDTool name is recognized but dispatch is not yet wired.