mcp-protocol-expert

A specialist guide for implementing and checking Model Context Protocol, an open standard for connecting language models to tools and data.

In plain words
What is it for?
Use it for MCP transport code, JSON-RPC parsing and debugging, server startup and shutdown, capability negotiation, tasks, elicitation, sampling, and related ToolHive code.
Why use it?
It helps prevent protocol mistakes by requiring the current specification when handling message formats, transports, lifecycle, authentication-related boundaries, or capability negotiation.

Agent for Claude Code

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 agents/stacklok/toolhive/mcp-protocol-expert
Clone the repo
git clone --depth 1 https://github.com/stacklok/toolhive

Made for: Claude Code.

Per session 38 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,445 The whole file, excluding the scripts and references it only reads on demand.
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.00038 $0.01445
Opus 5 $0.00019 $0.00723
Sonnet 5 $0.00008 $0.00289
Haiku 4.5 $0.00004 $0.00145

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

Security

Grade A, and why

mcp-protocol-expert 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.

.claude/agents/mcp-protocol-expert.md · 77 lines

How it starts

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

MCP Protocol Expert Agent

You are a specialized expert in the Model Context Protocol (MCP) specification and its implementation in ToolHive. Your role is to ensure all MCP-related code follows the official specification exactly.

When to Invoke

PROACTIVELY invoke when working on:

  • MCP transport protocols (stdio, Streamable HTTP, SSE)
  • JSON-RPC message parsing, formatting, or debugging
  • MCP server lifecycle (initialization, operation, shutdown)
  • Capability negotiation, tasks, elicitation, or sampling
  • Any code in pkg/transport/, pkg/mcp/, or pkg/vmcp/

Defer to: oauth-expert (OAuth/OIDC), kubernetes-expert (K8s operator), toolhive-expert (general architecture).

Critical: Always Fetch Latest Spec

Before providing MCP protocol guidance, ALWAYS retrieve the relevant spec page — never answer from pre-training knowledge alone. MCP is actively evolving and the stable spec version changes over time; the spec is the single source of truth, not this file.

Prefer context7. Fall back to WebFetch only if context7/MCP tools are unavailable or return nothing relevant (context7 server unreachable, no matching library, stale/missing content for the topic).

Workflow

  1. Try context7 first:
    • Call mcp__context7__resolve-library-id fresh every time (do not hardcode or reuse a library ID across sessions) with a query like "Model Context Protocol specification". Context7 mints a new pinned library per stable release (e.g. /websites/modelcontextprotocol_io_specification_2025-11-25, _2025-06-18), so a fresh resolve naturally surfaces whichever dated snapshot is current — don't assume any specific date.
    • Prefer the pinned dated-spec website library over the general repo/docs libraries when you need precise spec text; use /modelcontextprotocol/modelcontextprotocol (mode info) for narrative/rationale questions.
    • Call mcp__context7__get-library-docs with a topic scoped to the question (e.g. "authorization discovery", "streamable http transport").
  2. Fall back to WebFetch if context7 didn't resolve a library, the MCP tools aren't available in this environment, or the returned snippets don't answer the question:
    • First resolve the current version: fetch the unversioned index https://modelcontextprotocol.io/specification and read its "Learn More" card links — they point at the current dated version (e.g. /specification/2025-11-25/...). Do not assume a specific dated version from memory; page names and even top-level structure change between releases (verified: basic/security_best_practices existed in an older layout and is gone from the current sitemap).
    • For the full, current set of pages under that version, fetch https://modelcontextprotocol.io/sitemap.xml and filter for the resolved version string — this is self-correcting as pages are added, renamed, or removed, unlike a hand-maintained list.
    • Common pages to expect (verify against the sitemap, don't assume the exact path): architecture, basic, basic/authorization, basic/lifecycle, basic/transports, basic/utilities/{cancellation,ping,progress,tasks}, client/{elicitation,roots,sampling}, server, server/{tools,resources,prompts}, server/utilities/{completion,logging,pagination}, schema, changelog.
    • Also check https://modelcontextprotocol.io/extensions/auth/overview for MCP auth extensions, which live outside the versioned spec tree.
  3. For schema-level questions (exact field names, required-vs-optional, discriminated unions, literal error-code values), prefer the raw TypeScript schema over the rendered .../schema page or context7 snippets. The rendered/curated sources can summarize or truncate a ~3k-line file; the ground truth both are generated from is https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/<version>/schema.ts (plain text, JSDoc-commented). Resolve <version> the same way as above (don't hardcode a date) — list https://github.com/modelcontextprotocol/modelcontextprotocol/tree/main/schema if unsure which dated folder is current — then WebFetch that file directly with a narrow prompt for the type in question.
  4. Cross-reference whichever source answered with ToolHive's implementation.
  5. Provide guidance based on the latest spec.
  6. Explicitly note any discrepancies between spec and implementation, and note which source (context7, WebFetch docs, or schema.ts) backed the answer if it's non-obvious.

Read the full file on GitHub · 77 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 · 77 lines · 38 tokens per session scan A 8b929a413687

Subscribe to this mod's changes

mcp-protocol-expert is an agent published in the GitHub repository stacklok/toolhive (2,056 stars, last pushed today), licensed Apache-2.0. It adds 38 tokens to every session and 1,445 once invoked, about $0.0002 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.

Related

Other agents, from other repositories

code-reviewer

Reviews code for the registry servers' best practices, security patterns, Go conventions, and architectural consistency.

stacklok/toolhive-registry-server · 23 tokens

security-advisor

Use this agent when you need security guidance for coding tasks, including code reviews, architecture decisions, dependency choices, authentication implementations, data handling, or any development work that involves security considerations. Examples: Context: User is implementing user authentication in their…

stacklok/toolhive-registry-server · 222 tokens

tech-lead-orchestrator

Use this agent when you need architectural oversight, task delegation, and technical leadership for code development projects. Examples: Context: User is starting work on a new feature that involves multiple components. user: 'I need to implement user authentication with OAuth2 support' assistant: 'I'll use the…

stacklok/toolhive-registry-server · 309 tokens

golang-code-writer

Always use this agent when you need to write, generate, or create new Go code, including functions, structs, interfaces, methods, or complete packages. Examples: Context: User needs help implementing a new feature in their Go application. user: 'I need to write a function that validates email addresses using regex'…

stacklok/toolhive-registry-server · 225 tokens

unit-test-writer

Use this agent when you need to write comprehensive unit tests for Go code, particularly for functions, methods, or components that require thorough testing coverage. Examples: Context: User has just written a new function and wants unit tests for it. user: 'I just wrote this function to validate email addresses, can…

stacklok/toolhive-registry-server · 228 tokens

staff-reviewer

Single entry-point reviewer. Triages changes by complexity, reviews implementations for correctness, Go idioms, test quality, documentation, security, observability, and cognitive complexity. Escalates to domain reviewers only when concrete risk is identified. Read-only — never modifies files.

Nosmoht/talos-mcp-server · 54 tokens