java-sdk AGENTS.md

Project instructions for the MCP Java SDK, a Java library for building clients and servers that exchange tools and data through a shared protocol over several connection types.

In plain words
What is it for?
Use them when building or changing the SDK's core protocol, JSON handling, transports, client and server implementations, test fixtures, or protocol conformance tests.
Why use it?
They describe the SDK modules, Java and build requirements, formatting checks, and testing process, including tests that use Docker and npx.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/modelcontextprotocol/java-sdk/agents-md
Clone the repo
git clone --depth 1 https://github.com/modelcontextprotocol/java-sdk

Made for: Codex, OpenCode.

Per session 839 This file is loaded in full into every session.
When invoked 839 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00839 $0.00839
Opus 5 $0.00419 $0.00419
Sonnet 5 $0.00168 $0.00168
Haiku 4.5 $0.00084 $0.00084

Measured yesterday against content hash fd0ab747a14a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

java-sdk AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 81 lines

How it starts

The opening of the file, as written. The whole thing — 81 lines — stays where its author put it; the contents beside it link to each section on GitHub.

MCP Java SDK

Java SDK for the Model Context Protocol, enabling Java applications to implement MCP clients and servers (sync and async) over stdio, SSE, and Streamable HTTP transports.

Modules

  • mcp-core — protocol types, schema, client/server implementation, transports
  • mcp-json, mcp-json-jackson2, mcp-json-jackson3 — JSON binding abstraction + Jackson implementations
  • mcp — pom-only project, single dependency pulling both mcp-core and mcp-json-jackson3
  • mcp-bom — Maven BOM for dependency management
  • mcp-test — test fixtures shared across modules
  • mcp-test — test fixtures shared across modules
  • conformance-tests — client/server implementations run against the MCP conformance suite

Prerequisites

  • Java 17 or above
  • Docker
  • npx

Build & Test

./mvnw clean compile -DskipTests   # build
./mvnw test                        # tests (requires Docker + npx)

Formatting (spring-javaformat) is validated automatically as part of every build (bound to the validate phase), so a formatting violation fails ./mvnw test before any tests run. Fix violations with:

./mvnw spring-javaformat:apply

Evolving McpSchema records

Records in McpSchema are serialized directly to the MCP JSON wire format, so changing one is a wire-format change, not a routine refactor. Whether a field is optional (Java may leave it null) or spec-required by MCP determines a different set of rules — field ordering, @JsonCreator placement, default handling, and required test coverage. See the "Evolving wire-serialized records" section of CONTRIBUTING.md before touching a record in McpSchema; do not guess at the pattern from a single existing field.

Versioning & dependencies

  • The SDK follows semver; see VERSIONING.md for exactly what counts as a breaking change (it's broader than the obvious API removals — e.g. dropping a Java LTS version or a transport type also counts).
  • Dependency bumps require a concrete reason (security, bug, needed feature) — see DEPENDENCY_POLICY.md. Don't bump a dependency just because a newer version exists.

Read the full file on GitHub · 81 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 81 lines · 839 tokens per session scan A fd0ab747a14a

Subscribe to this mod's changes

java-sdk AGENTS.md is an instructions file published in the GitHub repository modelcontextprotocol/java-sdk (3,674 stars, last pushed 3d ago), licensed MIT. It adds 839 tokens to every session, about $0.0042 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.