MCP server for agents
One command turns JDogo into a Model Context Protocol server. Agents get tools to shrink data, build prompts, and compute exact answers locally instead of counting rows themselves.
Set it up
Build the CLI once, then point your MCP client at it. The server talks over standard input and output.
mvn -q package -pl jdogo-cli -am -DskipTests
{
"mcpServers": {
"jdogo": {
"command": "java",
"args": ["-jar", "/path/to/jdogo-cli-2.1.0.jar", "mcp", "start"]
}
}
}{
"mcpServers": {
"jdogo": {
"command": "java",
"args": ["-jar", "/path/to/jdogo-cli-2.1.0.jar", "mcp", "start"]
}
}
}java -jar jdogo-cli-2.1.0.jar mcp start
Claude Desktop reads claude_desktop_config.json; Cursor reads .cursor/mcp.json in your project or home folder.
The tools
| Tool | Arguments | Gives the agent |
|---|---|---|
jdogo_compute | expression, json | An exact count, sum, average, minimum or maximum, computed locally. See Compute expressions. |
jdogo_schema_card | json | Columns, types, ranges and examples in a few hundred tokens, whatever the table size |
jdogo_prompt | question, json | The prompt layout measured in live model runs, ready to send |
jdogo_compress | json | The data as a JDogo document, with its tokens (text plus the instruction a model needs) against JSON |
jdogo_decode | jdogo | JSON back from a JDogo document, exactly |
jdogo_tokens | text, encoding | Exact token counts (o200k or cl100k) |
jdogo_diff / jdogo_patch | snapshots and deltas | Only what changed between two states, and applying it |
A call with a missing or mistyped argument gets a JSON-RPC -32602 error naming the argument. When a tool runs and fails, for example on invalid JSON or a snapshot that fails its hash check, the result has isError: true and the reason, so the agent can correct its call.
Structured results and protocol versions
When the client negotiates MCP protocol version 2025-06-18 or newer, the two tools whose output is JSON data, jdogo_decode and jdogo_compute, include an outputSchema in tools/list and return both:
structuredContent: an object holding the JSON result, unchanged. MCP requires an object, sojdogo_decodeputs the decoded value undervalue;jdogo_computereturns{ok, value, error}.content: the same result as JSON text, for clients that read only text.
The tools that write for the model, such as jdogo_compress, jdogo_prompt and jdogo_schema_card, return JDogo text in content.
Older clients negotiating 2024-11-05 receive text in content with no structuredContent, keeping backward compatibility with earlier MCP drafts.
Always treat model-facing text as untrusted data: see Tool output is data.
The pattern that pays most
- The agent calls
jdogo_schema_cardon a large result instead of reading it. - It writes a query for the question, for example
count where status = "late". - It calls
jdogo_computeand gets the exact number back.
That is the ask() flow, run by the agent. In recorded runs, models that wrote queries got 150 of 150 counting questions right; reading the rows, the same models got 74.
Proxy any MCP server
You can optimize tool responses from any third-party MCP server without modifying it. The proxy sits between an MCP client and any stdio MCP server, runs the target server as a child process, and relays messages both ways. It rewrites only the model-facing text of large JSON tool results into JDogo when it strictly saves tokens.
java -jar jdogo-cli-2.1.0.jar mcp proxy [options] -- <server-command> [args...]
To use it in Claude Desktop, point the client at the proxy command:
{
"mcpServers": {
"filesystem": {
"command": "java",
"args": [
"-jar", "/path/to/jdogo-cli-2.1.0.jar",
"mcp", "proxy",
"--",
"npx", "-y", "@modelcontextprotocol/server-filesystem", "/workspace"
]
}
}
}What is and is not changed:
- Unchanged byte for byte: every message the proxy does not rewrite reaches the other side exactly as sent, line endings included.
structuredContent, error responses, results withisError: true, non-JSON text and anything other than atools/callresult are never modified. A block that already has_meta.jdogois left alone; when the proxy adds_meta.jdogo, other_metafields are kept. - The net-cost rule: A block is rewritten only when JDogo tokens plus the instruction tokens (
instructionFor) are strictly fewer than the original JSON tokens. A rewritten block decodes back to exactly the values of the original JSON, every digit of every number included, and token counts are recorded in per-block_meta.jdogo.
Options for measuring and tuning:
--dry-run: Measures and reports savings without altering any outgoing messages.--report: On exit, prints an intercepted token savings summary table to stderr. Its token columns cover the blocks it rewrote. In test runs withscripts/measure_mcp_proxy.py, those blocks took 46.5% fewer tokens (tables returned by our own server) and 38.5% fewer (generic records from a test server), instruction included.--exclude a,b: Tool names that are never rewritten.--min-chars N: Smallest JSON text to consider (default: 400).--encoding o200k_base|cl100k_base: Target tokenizer encoding (default: o200k_base).
In your own MCP server
Already run a Java MCP server? Compact any tool result before returning it:
var optimizer = new McpToolOptimizer(); // or new McpToolOptimizer(JDogoOptimizer.builder().build(), true)
McpToolResponse res = optimizer.optimize(products, Map.of("tool", "search_products"));
// res.getContent() holds the JDogo text; the metadata adds jdogo_format and jdogo_token_countIn Python and TypeScript, wrap tool functions with @jdogo_tool or createJDogoTool; see Integrations.