The Clojure SDK for Model Context Protocol (MCP) Servers is a powerful tool designed to help developers create MCP servers (and eventually clients) using Clojure. This SDK simplifies the process of building and deploying MCP servers, enabling developers to focus on implementing their specific functionalities.
To build the examples jar, run the following command:
$ make clean && make examples-jar
The examples jar includes the following servers:
1. Calculator Server
2. Vega-lite Server
3. Code Analysis Server
The calculator_server
provides basic arithmetic tools. Example commands you can try in Claude Desktop or Inspector:
In Claude Desktop:
"calculator": {
"command": "java",
"args": [
"-Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory",
"-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog",
"-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector",
"-Dlog4j2.configurationFile=log4j2-mcp.xml",
"-Dbabashka.json.provider=metosin/jsonista",
"-Dlogging.level=INFO",
"-cp",
"/Users/vedang/mcp-clojure-sdk/examples/target/io.modelcontextprotocol.clojure-sdk/examples-1.2.0.jar",
"calculator_server"
]
}
In MCP Inspector:
npx @modelcontextprotocol/inspector java -Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory -Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector -Dlog4j2.configurationFile=log4j2-mcp.xml -Dbabashka.json.provider=metosin/jsonista -Dlogging.level=INFO -cp examples/target/io.modelcontextprotocol.clojure-sdk/examples-1.2.0.jar calculator_server
The vegalite_server
generates Vega-lite charts for data visualization. Example commands you can try in Claude Desktop or Inspector:
[
{ "year": 2011, "value": 14.6, "growth_type": "Market Cap Growth" },
{ "year": 2011, "value": 11.4, "growth_type": "Revenue Growth" },
{ "year": 2011, "value": 26.6, "growth_type": "Net Income Growth" },
{ "year": 2012, "value": 40.1, "growth_type": "Market Cap Growth" },
{ "year": 2012, "value": 42.7, "growth_type": "Revenue Growth" },
{ "year": 2012, "value": 36.9, "growth_type": "Net Income Growth" },
{ "year": 2013, "value": 16.9, "growth_type": "Market Cap Growth" },
{ "year": 2013, "value": 14.6, "growth_type": "Revenue Growth" },
{ "year": 2013, "value": 15.3, "growth_type": "Net Income Growth" },
{ "year": 2014, "value": 9.6, "growth_type": "Market Cap Growth" },
{ "year": 2014, "value": 7.9, "growth_type": "Revenue Growth" },
{ "year": 2014, "value": 10.9, "growth_type": "Net Income Growth" },
{ "year": 2015, "value": 5.8, "growth_type": "Market Cap Growth" },
{ "year": 2015, "value": 6.7, "growth_type": "Revenue Growth" },
{ "year": 2015, "value": 6.2, "growth_type": "Net Income Growth" },
{ "year": 2016, "value": -12.4, "growth_type": "Market Cap Growth" },
{ "year": 2016, "value": -3.9, "growth_type": "Revenue Growth" },
{ "year": 2016, "value": -32.2, "growth_type": "Net Income Growth" },
{ "year": 2017, "value": 25.3, "growth_type": "Market Cap Growth" },
{ "year": 2017, "value": 5.9, "growth_type": "Revenue Growth" },
{ "year": 2017, "value": 43.9, "growth_type": "Net Income Growth" }
]
In Claude Desktop:
"vegalite": {
"command": "java",
"args": [
"-Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory",
"-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog",
"-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector",
"-Dlog4j2.configurationFile=log4j2-mcp.xml",
"-Dbabashka.json.provider=metosin/jsonista",
"-Dlogging.level=INFO",
"-Dmcp.vegalite.vl_convert_executable=/Users/vedang/.cargo/bin/vl-convert",
"-cp",
"/Users/vedang/mcp-clojure-sdk/examples/target/io.modelcontextprotocol.clojure-sdk/examples-1.2.0.jar",
"vegalite_server"
]
}
In MCP Inspector:
npx @modelcontextprotocol/inspector java -Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory -Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector -Dlog4j2.configurationFile=log4j2-mcp.xml -Dbabashka.json.provider=metosin/jsonista -Dlogging.level=INFO -Dmcp.vegalite.vl_convert_executable=/Users/vedang/.cargo/bin/vl-convert -cp examples/target/io.modelcontextprotocol.clojure-sdk/examples-1.2.0.jar vegalite_server
The code_analysis_server
provides prompts for code analysis and generating poems about code.
In Claude Desktop:
"code-anaylsis": {
"command": "java",
"args": [
"-Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory",
"-Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog",
"-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector",
"-Dlog4j2.configurationFile=log4j2-mcp.xml",
"-Dbabashka.json.provider=metosin/jsonista",
"-Dlogging.level=INFO",
"-cp",
"/Users/vedang/mcp-clojure-sdk/examples/target/io.modelcontextprotocol.clojure-sdk/examples-1.2.0.jar",
"code_analysis_server"
]
}
In MCP Inspector:
npx @modelcontextprotocol/inspector java -Dclojure.tools.logging.factory=clojure.tools.logging.impl/log4j2-factory -Dorg.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector -Dlog4j2.configurationFile=log4j2-mcp.xml -Dbabashka.json.provider=metosin/jsonista -Dlogging.level=INFO -cp examples/target/io.modelcontextprotocol.clojure-sdk/examples-1.2.0.jar code_analysis_server
For a list of pending changes, check the todo.org file.
The clojure-sdk
is a standard deps-new
project. Use the following commands for development:
$ make test
or clojure -T:build test
$ make build
or clojure -T:build ci
$ make install
or clojure -T:build install
$ make deploy
or clojure -T:build deploy
This SDK is built on top of lsp4clj, which handles the edge-cases of a JSON-RPC based server.
Distributed under the MIT License. Copyright © 2025 Unravel.tech.