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.
Run the server
Section titled “Run the server”The default transport is stdio, which is what MCP clients spawn directly:
wayland-core mcp-serveFor a networked setup, use SSE. It binds to loopback on port 9876 by default:
wayland-core mcp-serve --transport sse --bind 127.0.0.1:9876The --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.
Arguments
Section titled “Arguments”| Argument | Default | Notes |
|---|---|---|
--transport | stdio | stdio or sse. |
--bind | 127.0.0.1:9876 | SSE only. Ignored for stdio. |
The stdio transport runs until end of input. The SSE transport runs until it is aborted.
What the server advertises
Section titled “What the server advertises”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.
Policy gating
Section titled “Policy gating”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.
Consume from an MCP client
Section titled “Consume from an MCP client”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.
Error codes
Section titled “Error codes”| Code | Name | When |
|---|---|---|
-32600 | INVALID_REQUEST | jsonrpc field is not "2.0". |
-32601 | METHOD_NOT_FOUND | Unknown method or unknown tool name in tools/call. |
-32602 | INVALID_PARAMS | tools/call params are missing or name is absent. |
-32001 | POLICY_DENIED | Policy gate blocked the tool. |
-32002 | NOT_IMPLEMENTED | Tool name is recognized but dispatch is not yet wired. |