### Start mcp-clj Server in Clojure Source: https://github.com/hugoduncan/mcp-clj/blob/master/README.md Example of requiring the `mcp-clj.mcp-server.core` namespace and creating an MCP server instance on a specified port (e.g., 3001). This code snippet demonstrates how to initialize and run the server component of mcp-clj. ```clojure (require 'mcp-clj.mcp-server.core) (def server (mcp-clj.mcp-server.core/create-server {:port 3001})) ``` -------------------------------- ### Clojure JSON-RPC Server Example Usage and Shutdown Source: https://github.com/hugoduncan/mcp-clj/blob/master/doc/adr/001-json-rpc-server.md This snippet provides a full example of instantiating and managing the JSON-RPC server. It shows how to call `create-server` with a port and a map of method names to handler functions. It also demonstrates how to cleanly shut down the server by invoking the `:stop` function returned by `create-server`. ```clojure ;; Create server with handlers returning EDN (def server (create-server {:port 8080 :handlers {"echo" (fn [params] {:result params}) ; EDN map returned "get-config" (fn [params] {:result {:enabled? true :features [:a :b :c] :updated-at #inst "2024"}})}})) ;; Stop server when done ((:stop server)) ``` -------------------------------- ### Clojure Example JSON-RPC Handler Returning EDN Source: https://github.com/hugoduncan/mcp-clj/blob/master/doc/adr/001-json-rpc-server.md This example demonstrates a concrete Clojure handler function. It takes `params` and returns a map containing a `:result` key, which holds structured EDN data including keywords, vectors, and an instant. This illustrates how handlers produce native EDN data that the server will automatically convert to JSON. ```clojure (defn example-handler [params] {:result {:status :ok :data [1 2 3] :meta {:timestamp #inst "2024"}}}) ;; EDN data structures ``` -------------------------------- ### Configure Claude Desktop with mcp-proxy Source: https://github.com/hugoduncan/mcp-clj/blob/master/README.md JSON configuration snippet for `claude_desktop_config.json` to integrate `mcp-proxy` with `mcp-clj`. It specifies the command to run `mcp-proxy`, arguments including the SSE endpoint, and environment variables like `API_ACCESS_TOKEN` for authentication. ```json "mcp-proxy": { "command": "mcp-proxy", "args": [ "http://localhost:3001/sse" ], "env": { "API_ACCESS_TOKEN": "ABC" } } ``` -------------------------------- ### Define Clojure JSON-RPC Server Creation Interface Source: https://github.com/hugoduncan/mcp-clj/blob/master/doc/adr/001-json-rpc-server.md This snippet defines the interface for creating a JSON-RPC server instance in Clojure. The `create-server` function takes a configuration map and returns a map containing the server object and a function to stop the server. Key configuration parameters include `:port` for listening and `:handlers` for method dispatch. ```clojure (create-server config) -> {:server server-object :stop (fn [] ...)} ``` -------------------------------- ### Add mcp-clj Dependency to Clojure Project Source: https://github.com/hugoduncan/mcp-clj/blob/master/README.md Instructions on how to add `mcp-clj` as a Git dependency to a Clojure project's `deps.edn` configuration, specifying the Git URL, SHA, and root path within the repository. ```clojure :deps {org.hugoduncan/mcp-clj {:git/url "https://github.com/hugoduncan/mcp-clj" :git/sha "replace with latest git sha" :deps/root "projects/server"}} ``` -------------------------------- ### Define Clojure JSON-RPC Handler Function Signature Source: https://github.com/hugoduncan/mcp-clj/blob/master/doc/adr/001-json-rpc-server.md This snippet specifies the required signature for handler functions used by the JSON-RPC server. Each handler function must accept a `params` argument (representing the JSON-RPC request parameters, converted to EDN) and is expected to return an EDN data structure as its response. ```clojure (handler-fn params) -> edn-response ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.