Liking cljdoc? Tell your friends :D

MCP API

Module: im.ttalk/clj-agent-mcp

Source: modules/clj-agent-mcp/src

Client

Namespace: im.ttalk.agent.mcp.client

(require '[im.ttalk.agent.mcp.client :as client]
         '[im.ttalk.agent.mcp.transport :as transport])

(def c (client/client {:transport (transport/http-transport {:url "https://example.com/mcp"})}))
(client/connect! c)
(client/list-tools c)
(client/call-tool c "search" {"query" "clojure"})
FunctionContract
clientCreate a client; no network call yet
connect!Negotiate protocol capabilities; idempotent
list-toolsReturn the server's raw tool descriptors
call-toolCall a tool and return its MCP result
read-resourceRead an MCP resource
get-promptRead an MCP prompt template
instructionsServer usage guidance suitable for a system prompt
request!Send a named protocol request

Transports are in im.ttalk.agent.mcp.transport: Streamable HTTP and stdio. A plain (fn [message] response) is also a valid transport for tests.

Server

Namespace: im.ttalk.agent.mcp.server

(def s (mcp/server {:name "my-server"
                    :version "1.0"
                    :tools [weather-tool]
                    :instructions "Use tools only when needed."}))

handle-message is a pure one-message-in/one-response-out function and is the preferred entry point for HTTP hosts. stdio-server! runs the stdio transport and blocks until stdin closes. The server reports only capabilities it can actually serve.

Protocol constants and envelopes are isolated in im.ttalk.agent.mcp.protocol. It supports the modern per-request protocol era and the legacy initialize handshake era.

Tool bridging

Namespace: im.ttalk.agent.mcp.tools

FunctionPurpose
connect-serversConnect to servers and list converted tools
->inline-toolConvert one MCP tool descriptor to an inline tool map
with-toolsMerge converted MCP tools into an agent configuration
result-textRender an MCP result for the LLM history
app-toolsIdentify tools advertising MCP Apps UI resources

MCP tools become ordinary inline tools from the agent loop's perspective, while retaining annotations needed for approval and UI integration.

Can you improve this documentation?Edit on GitHub

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