Expand description
A small Model Context Protocol tools server.
The crate speaks MCP’s JSON-RPC 2.0 messages and knows nothing about HTTP or the app:
a front end (an axum POST /mcp route, a gRPC bridge, a test) passes each decoded message
to Server::handle with the caller’s bearer token, and the app implements Tools::call.
The server is stateless, so it fits MCP’s streamable HTTP transport with JSON responses.
ToolSpec/Param: static tool tables withreadOnlyHint,destructiveHintandopenWorldHintannotations, and an auth flag that adds “Requires a bearer token.” to the description.args: typed argument getters with uniform error messages.stdio: the<app>ctl mcploop that forwards stdio messages to a remote server.
Modules§
- args
- Argument getters with uniform messages (
missing string argument "name"). - codes
- JSON-RPC error codes used here.
- stdio
- The stdio bridge behind
<app>ctl mcp: read one JSON-RPC message per line, forward it, write the reply on its own line. Transport failures become a JSON-RPC internal error for requests that have an id; notifications get nothing.
Structs§
- Param
- One tool parameter.
- Server
- The MCP server.
- Server
Info - What
initializereports. - Tool
Error - A tool failure, reported to the model as an
isErrorresult (not a JSON-RPC error). - Tool
Spec - A tool.
Enums§
- Param
Type - JSON Schema type of a parameter.
Constants§
- PROTOCOL_
VERSIONS - Protocol versions this server negotiates, newest first.
Traits§
- Tools
- The app side: runs a tool.
Functions§
- rpc_err
- A JSON-RPC error.
- rpc_ok
- A JSON-RPC success.
- tool_
error - A failed tool result.
- tool_ok
- A successful tool result: pretty JSON text plus
structuredContent.