Handles JSON RPC interface and dispatches to an MCP server. Babashka-compatible version using cheshire for JSON.
Handles JSON RPC interface and dispatches to an MCP server. Babashka-compatible version using cheshire for JSON.
(->server {:keys [protocol-version name version initialize tools resources
prompts on-receive on-send enqueue-notification]
:or {protocol-version schema/latest-protocol-version
initialize (fn [_init-params])}})Returns a reified instance of AServer (an MCP Server), given tools, resources and prompts. Only tools are supported at this time.
Returns a reified instance of AServer (an MCP Server), given tools, resources and prompts. Only tools are supported at this time.
(format-tool-results results)Format a tool result into the expected JSON-RPC text response format.
Format a tool result into the expected JSON-RPC text response format.
(handle-message server message send-notification)Returns a JSON-RPC message.
Returns a JSON-RPC message.
(handle-notification {:as _notification :keys [method]})We don't need to do anything special for notifications right now.
We don't need to do anything special for notifications right now.
(handle-request mcp-server
{:as request :keys [id method params]}
&
[send-notification])Router for AServer - dispatches to appropriate handler based on method.
Router for AServer - dispatches to appropriate handler based on method.
(handle-tool-call-request server {:as _request :keys [id params]})Handles tools/call request and invokes tool. Returns JSON-RPC result or error.
Handles tools/call request and invokes tool. Returns JSON-RPC result or error.
(notification? {:as _message :keys [method id]})Notifications have method, but no id.
Notifications have method, but no id.
(read-json-rpc-message)Reads a JSON value from stdin and coerces map string keys to keywords. Returns parse error on JSON parse exception.
Reads a JSON value from stdin and coerces map string keys to keywords. Returns parse error on JSON parse exception.
(start-server! server)Main server loop - reads from stdin, writes to stdout.
Main server loop - reads from stdin, writes to stdout.
(write-json-rpc! message)Writes JSON to stdout with locking for thread safety. Returns string written on success, nil otherwise.
Writes JSON to stdout with locking for thread safety. Returns string written on success, nil otherwise.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |