Liking cljdoc? Tell your friends :D

modex-bb.mcp.server

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.
raw docstring

->serverclj

(->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.
sourceraw docstring

format-tool-errorsclj

(format-tool-errors errors)
source

format-tool-resultsclj

(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.
sourceraw docstring

handle-messageclj

(handle-message server message send-notification)

Returns a JSON-RPC message.

Returns a JSON-RPC message.
sourceraw docstring

handle-notificationclj

(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.
sourceraw docstring

handle-requestclj

(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.
sourceraw docstring

handle-tool-call-requestclj

(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.
sourceraw docstring

notification?clj

(notification? {:as _message :keys [method id]})

Notifications have method, but no id.

Notifications have method, but no id.
sourceraw docstring

read-json-rpc-messageclj

(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.
sourceraw docstring

start-server!clj

(start-server! server)

Main server loop - reads from stdin, writes to stdout.

Main server loop - reads from stdin, writes to stdout.
sourceraw docstring

write-json-rpc!clj

(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.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close