MCP Server Specification Template (Model Context Protocol)
Transport, discovery, capabilities, tools, CacheableResult, MRTR confirmation and requestState, OAuth, OWASP 2026 mapping, errors, tests
How to use: Use it when exposing a system to AI applications over the Model Context Protocol. Confirm the target protocol revision and transport first, then define each tool with schema, annotations and side effects. The main pitfall is treating tool annotations as a security control and skipping input validation and audience-bound tokens.
Preview
MCP Server Specification: [Server name]
Specification for a Model Context Protocol (MCP) server: what it exposes to AI applications (tools, resources, prompts), over which transport, with which authorization, how it asks the user for more input, and how it is secured, observed, tested and versioned. Written against MCP specification revision 2026-07-28 (the latest revision on modelcontextprotocol.io as of October 2026; previous revision 2025-11-25). The security section is mapped to the OWASP Top 10 for LLM Applications 2026 and the OWASP Top 10 for Agentic Applications for 2026. Check the current revision before you start. Replace every
[bracketed]value and every row marked Example. Worked examples use a fictional billing service, "Larkspur Billing".
Document control
| Field | Value |
|---|---|
| Document ID | [MCP-SPEC-001] |
| Server name and version | [larkspur-billing-mcp] [1.0.0] |
| Target MCP revision | [2026-07-28]; backward compatible with [2025-11-25 / none] |
| Status | [Draft / In review / Approved / Deprecated] |
| Owner | [@owner] |
| Reviewers | [@security-reviewer], [@platform-engineer] |
| Repository | [URL] |
| Classification | [Internal / Confidential] |
| Last updated | YYYY-MM-DD |
| Security frameworks | OWASP Top 10 for LLM Applications 2026; OWASP Top 10 for Agentic Applications for 2026 |
| Related documents | [AI agent specification], [Agent tool permission design], [Tool catalogue entry], [API specification] |
Approvals
| Role | Name | Decision | Date |
|---|---|---|---|
| Server owner | [@name] | [Approved / Approved with conditions / Rejected] | YYYY-MM-DD |
| Security reviewer | [@name] | [Decision] | YYYY-MM-DD |
| Data protection or privacy lead (if personal data flows) | [@name] | [Decision] | YYYY-MM-DD |
Revision history
| Version | Date | Author | Change |
|---|---|---|---|
| 0.1 | YYYY-MM-DD | [@name] | First draft |
| Example: 0.2 | YYYY-MM-DD | [@name] | Moved user confirmation of credits over 25 USD to an elicitation request (section 6) |
| 1.0 | YYYY-MM-DD | [@name] | Approved for production |
Contents
- Purpose and context
- Transport and protocol
- Capabilities and extensions
- Tools
- Resources, prompts and caching
- User input and confirmation (multi round-trip requests)
- Authorization
- Security considerations and OWASP mapping
- Error handling
- Logging and observability
- Versioning, compatibility and deprecation
- Testing
- Glossary and references
1. Purpose and context
[Describe the system the server wraps and who will connect to it.] Example: Exposes read access to invoices and a limited credit operation from the Larkspur billing service, for use by the internal support assistant and by engineers in their IDE assistants. It does not expose payment card data, refunds or account deletion.
| Item | Value |
|---|---|
| Wrapped system | Example: Billing API v4 |
| Intended hosts | Example: Support assistant (remote), IDE assistants (local) |
| Users | Example: Support staff and billing engineers |
| Data classification | Example: Confidential (customer billing data) |
| Out of scope | Example: Card data, refunds, account closure, bulk export |
| Deployment | Example: Remote server behind the company gateway; a local stdio build for development only |
2. Transport and protocol
| Aspect | Choice |
|---|---|
| Transport | [stdio / Streamable HTTP / both] |
| Endpoint (HTTP) | [https://mcp.larkspur.example/mcp] single MCP endpoint accepting POST |
| Response modes | [JSON object / request-scoped SSE stream] per request |
| Discovery | server/discover returns supported versions, capabilities and server identity |
| Request metadata | Each request carries io.modelcontextprotocol/protocolVersion and io.modelcontextprotocol/clientCapabilities in _meta; clients should add io.modelcontextprotocol/clientInfo |
| Server identity | Each result carries io.modelcontextprotocol/serverInfo in _meta |
| Change notifications | [subscriptions/listen for list changes / not used] |
| Older clients | [Fallback to initialize-based revisions: yes or no] |
Transport requirements to verify:
- stdio: newline-delimited JSON-RPC on stdin and stdout; logs go to
stderr only; credentials come from the environment, not from MCP
authorization. Clients may call
server/discoverfirst as a compatibility probe. - Streamable HTTP: validate the
Originheader on every request and answer 403 when it is present and invalid (DNS rebinding protection); bind to 127.0.0.1 when running locally; require theMCP-Protocol-Version,Mcp-Methodand (fortools/call,resources/read,prompts/get)Mcp-Nameheaders and reject header-body mismatches as aHeaderMismatchError(code -32020). - No resumability: the 2026-07-28 revision removed SSE event IDs and
Last-Event-ID. A broken response stream loses the in-flight request and the client re-issues it with a new request ID, so write tools must tolerate a retry (see the idempotency key in section 4.1). - Statelessness: no per-connection state and no
Mcp-Session-Id. Where a tool needs state across calls, return an explicit opaque handle and accept it as an argument, checking authorization on every call. The same request may land on any replica.
3. Capabilities and extensions
| Capability | Declared | Notes |
|---|---|---|
tools | [Yes] | listChanged: [true / false]; tools/list returned in a deterministic order |
resources | [Yes / No] | Change subscriptions through subscriptions/listen: [yes / no] |
prompts | [Yes / No] | listChanged: [true / false] |
completions | [Yes / No] | Argument completion for prompts and resource templates |
extensions | [None / list] | Example: io.modelcontextprotocol/tasks for long-running exports |
| Deprecated features | Not used | Roots, Sampling and Logging are deprecated in 2026-07-28; HTTP+SSE transport and Dynamic Client Registration are also deprecated |
Client capabilities this server relies on:
| Client capability | Used for | Behaviour if absent |
|---|---|---|
elicitation | Example: Confirming credits over 25 USD (section 6) | apply_credit above 25 USD returns isError: true asking the host to obtain confirmation by other means |
| [Capability] | [Use] | [Fallback] |
4. Tools
| ID | Name | Title | Side effects | readOnlyHint | destructiveHint | idempotentHint | openWorldHint |
|---|---|---|---|---|---|---|---|
| TL-001 (Example) | get_invoice | Get invoice | None | true | n/a | n/a | false |
| TL-002 (Example) | search_invoices | Search invoices | None | true | n/a | n/a | false |
| TL-003 (Example) | apply_credit | Apply account credit | Writes a ledger entry | false | false | true (with idempotency key) | false |
Defaults in the schema, if a hint is omitted: readOnlyHint false,
destructiveHint true, idempotentHint false, openWorldHint true. Set
every hint explicitly so clients do not assume the worst or the best.
Since 2026-07-28, inputSchema and outputSchema may use any JSON
Schema 2020-12 keyword; keep schemas simple anyway, because models follow
flat, well-described schemas more reliably.
4.1 Tool definition: apply_credit
{
"name": "apply_credit",
"title": "Apply account credit",
"description": "Add a credit in USD to a customer account. Use only after confirming the charge is a duplicate or caused by an outage. Maximum 50 USD. Amounts over 25 USD need the user's confirmation. Creates a ledger entry that finance can reverse within 30 days.",
"inputSchema": {
"type": "object",
"properties": {
"account_id": {"type": "string", "pattern": "^acc_[a-z0-9]{12}$"},
"amount_usd": {"type": "number", "minimum": 0.01, "maximum": 50},
"reason_code": {"type": "string", "enum": ["DUPLICATE_CHARGE", "SERVICE_OUTAGE"]},
"idempotency_key": {"type": "string", "minLength": 16, "maxLength": 64}
},
"required": ["account_id", "amount_usd", "reason_code", "idempotency_key"],
"additionalProperties": false
},
"outputSchema": {
"type": "object",
"properties": {"credit_id": {"type": "string"}, "balance_usd": {"type": "number"}},
"required": ["credit_id", "balance_usd"]
},
"annotations": {"readOnlyHint": false, "destructiveHint": false, "idempotentHint": true, "openWorldHint": false}
}
Results with an outputSchema return structuredContent that conforms to
it, plus the same JSON serialised in a text content block for older
clients. Every result carries resultType: "complete" for an ordinary
result, "input_required" for an interim result (section 6). Clients
treat results from older servers without the field as complete.
4.2 Tool description review
Check each description against these questions before approval:
- Does it say when to use the tool and when not to?
- Does it state every side effect and limit in words the model can act on?
- Does it avoid instructions that depend on content returned by other tools (a route for injected text to steer the model)?
- Does it avoid internal hostnames, secrets or policy details the user should not see? Tool schemas are part of the model's hidden context and should be assumed readable (OWASP LLM08:2026).
5. Resources, prompts and caching
5.1 Resources
| URI or template | Name | MIME type | Description | ttlMs | cacheScope |
|---|---|---|---|---|---|
billing://policy/credits | Example: Credit policy | text/markdown | Current credit rules | 3,600,000 | public |
billing://invoices/{invoice_id} | Example: Invoice | application/json | One invoice | 60,000 | private |
5.2 Prompts
| Name | Arguments | Purpose |
|---|---|---|
explain_invoice | Example: invoice_id (required), language (optional) | Produces a customer-friendly explanation of each line item |
5.3 Cache policy (CacheableResult)
Results of tools/list, prompts/list, resources/list,
resources/read and resources/templates/list must carry ttlMs (a
freshness hint in milliseconds) and cacheScope ("public" or
"private"). Shared intermediaries may cache only public results.
| Result | ttlMs | cacheScope | Reason |
|---|---|---|---|
tools/list | Example: 300,000 | private | Tool visibility depends on the token's scopes (section 7) |
prompts/list | Example: 3,600,000 | public | Same for every user |
resources/read of an invoice | Example: 60,000 | private | User-specific data |
Rule of thumb: anything that varies by user, tenant or scope is
private. Keep listChanged notifications as well; the TTL complements
them and does not replace them.
6. User input and confirmation (multi round-trip requests)
The multi round-trip requests (MRTR) pattern replaces server-initiated
elicitation/create, sampling/createMessage and roots/list calls.
The server returns resultType: "input_required" with inputRequests
(a map of requests for the client to fulfil) and an optional opaque
requestState. The client gathers the answers and retries the original
request, with a new JSON-RPC ID, carrying inputResponses and the exact
requestState.
| ID | Request | When input is required | Input requested | Fallback if the client lacks the capability |
|---|---|---|---|---|
| MR-001 (Example) | tools/call apply_credit | Amount over 25 USD | Form elicitation: confirm amount and reason | isError: true, "confirmation required, amount over 25 USD" |
| [MR-nnn] | [Request] | [Condition] | [Input] | [Fallback] |
requestState controls (the specification treats it as
attacker-controlled input):
| Control | Design |
|---|---|
| Integrity | Example: AEAD-encrypted with a key held in the secrets manager, rotated every [90] days |
| Principal binding | Example: Contains the authenticated user ID; rejected if presented by another user |
| Expiry | Example: 5 minutes |
| Request binding | Example: Method name plus a digest of account_id, amount_usd and idempotency_key |
| Single use | Example: Idempotency key stored server-side, so a replayed state cannot apply a second credit |
Only send input requests for capabilities the client declared. Never assume the client will retry; a credit that was never confirmed is simply not applied.
7. Authorization
| Aspect | Design |
|---|---|
| Model | MCP server acts as an OAuth 2.1 resource server |
| Protected Resource Metadata | Example: https://mcp.larkspur.example/.well-known/oauth-protected-resource (RFC 9728) listing the authorization server |
| Authorization server | Example: Corporate identity provider with RFC 8414 or OpenID Connect discovery; includes iss in authorization responses (RFC 9207) |
| Client registration | Client ID Metadata Documents preferred; pre-registration for internal hosts; Dynamic Client Registration only for compatibility (deprecated in 2026-07-28) |
| Token validation | Audience must be this server's canonical URI (RFC 8707 resource indicator); reject other tokens; no token passthrough to the billing API |
| Scopes | Example: invoices:read, credits:write; 401 and 403 responses carry the required scope in WWW-Authenticate |
| Tool visibility | Example: tools/list returns apply_credit only to tokens with credits:write |
| Downstream calls | Example: Server uses its own service credentials with per-user audit fields |
Client-side duties to tell host teams about: validate a present iss
against the recorded issuer before redeeming the code, and key stored
client credentials by issuer, re-registering if the authorization server
changes.
8. Security considerations and OWASP mapping
| ID | Concern | Control | Test |
|---|---|---|---|
| MS-01 | User consent before state changes | Write tools marked readOnlyHint: false; confirmation through MRTR elicitation over 25 USD (section 6); server enforces limits regardless | Host test and MRTR replay test |
| MS-02 | Least privilege | Separate scopes for read and write; service account limited to the credit endpoint | Scope test matrix |
| MS-03 | Input validation | JSON Schema validation plus business checks (account ownership, daily cap of [200] USD per agent) | Unit and fuzz tests |
| MS-04 | Untrusted content in results | Invoice memo fields returned as data in structuredContent; no instructions in tool descriptions that depend on returned text | Injection test set |
| MS-05 | Rate limiting | Example: 30 tools/call per minute per user | Load test |
| MS-06 | Output sanitisation | Card numbers masked; no secrets in results or errors | Snapshot tests |
| MS-07 | DNS rebinding (HTTP) | Origin validation; localhost binding for local mode | Integration test |
| MS-08 | Sensitive headers | No secrets or personal data in x-mcp-header parameters | Code review |
| MS-09 | Tampered or replayed requestState | AEAD, principal, expiry and request binding (section 6) | Tamper and replay tests |
| MS-10 | Supply chain | Pinned SDK version, signed release, SBOM published with each version | Dependency scan in CI |
| MS-11 | Hidden context exposure | Tool descriptions and errors hold no internal hostnames, keys or policy thresholds beyond what the model needs | Description review (section 4.2) |
The IDs and short names below follow the OWASP Top 10 for LLM Applications 2026 (OWASP GenAI Security Project, published 3 August 2026) and the OWASP Top 10 for Agentic Applications for 2026 (published 9 December 2025). Cite the year with each ID, because numbering changed between editions. Check the current lists at https://genai.owasp.org/.
| OWASP ID | Risk | Controls in this server | Handled elsewhere |
|---|---|---|---|
| LLM01:2026 | Prompt Injection | MS-04, MS-11 | Host input guardrails |
| LLM02:2026 | Sensitive Information Disclosure | MS-02, MS-06, private cache scope | Data classification policy |
| LLM03:2026 | Excessive Agency | MS-01, MS-02, MS-03 | Agent tool permission design |
| LLM04:2026 | Supply Chain | MS-10 | AI bill of materials |
| LLM06:2026 | Unbounded Consumption | MS-05 | Gateway quotas |
| LLM08:2026 | Hidden Context Exposure | MS-11 | Prompt specification |
| LLM10:2026 | Improper Output Handling | MS-06, structuredContent with schema | Host rendering |
| ASI02 | Tool Misuse and Exploitation | MS-01, MS-03, MS-05 | Agent tool permission design |
| ASI03 | Identity and Privilege Abuse | Section 7 audience check, no token passthrough, MS-09 | Identity provider policies |
| ASI04 | Agentic Supply Chain Vulnerabilities | MS-10, pinned server version in the host registry | Tool catalogue |
Entries not listed (for example LLM05:2026 Data and Model Poisoning and LLM09:2026 Vector and Embedding Weaknesses) do not apply to this server because it trains nothing and holds no vector index. Say so explicitly for your own server rather than leaving gaps.
9. Error handling
| Situation | Response |
|---|---|
| Unknown tool, malformed request, resource not found | JSON-RPC error -32602 Invalid params (resource not found moved from -32002 in 2026-07-28) |
| Header and body disagree (HTTP) | HeaderMismatchError, code -32020 |
| Required client capability missing | MissingRequiredClientCapability, code -32021 |
| Unsupported protocol version | UnsupportedProtocolVersionError, code -32022, listing supported versions |
| Validation or business rule failure | Tool result with isError: true and an actionable message, for example "amount_usd must be 50 or less" |
| Backend unavailable | Tool result with isError: true, "billing service unavailable, retry later" |
Expired or invalid requestState or handle | isError: true explaining that the request must start again |
Codes -32000 to -32019 remain implementation-defined; -32020 to
-32099 are reserved for the MCP specification, so do not allocate your
own codes there.
10. Logging and observability
[Example: Structured logs to stderr (stdio) or the platform log pipeline
(HTTP) with request ID, method, tool name, user ID, latency and outcome.
Arguments are logged with account IDs hashed. Trace context is propagated
through the _meta keys traceparent, tracestate and baggage into
OpenTelemetry. Audit log of every apply_credit call kept for [7]
years.]
| Signal | Content | Destination | Retention |
|---|---|---|---|
| Trace span per request | Method, tool name, result type, latency, error code | Example: OpenTelemetry collector | 30 days |
| Audit event per write | User, account (hashed), amount, reason, idempotency key, outcome | Example: Append-only audit store | 7 years |
| Client-visible log messages | Only when the request's _meta sets io.modelcontextprotocol/logLevel | Response stream of that request | None on the server side |
11. Versioning, compatibility and deprecation
- Server version follows semantic versioning; a breaking change to any tool's input schema or behaviour is a major version.
- Tools are added rather than changed; deprecated tools keep working for [90] days and say so in their description.
- Supported MCP revisions: [2026-07-28]; [2025-11-25 via fallback].
listChangednotifications are sent throughsubscriptions/listenwhen the tool set changes at runtime.- Review the MCP deprecated features registry at each release. The feature lifecycle policy gives at least twelve months between deprecation and removal; record each deprecated feature this server still uses and its removal plan below.
| Deprecated feature | Used by this server | Plan |
|---|---|---|
| Roots, Sampling, Logging | Example: No | Not adopted |
| Dynamic Client Registration | Example: Yes, for one legacy host | Move host to Client ID Metadata Document by YYYY-MM-DD |
12. Testing
| Test | Tool | Pass criteria |
|---|---|---|
| Interactive check | MCP Inspector (npx @modelcontextprotocol/inspector) | All tools, resources and prompts listed and callable with valid inputs |
| Schema conformance | Contract tests against the published schema | All results validate; resultType present; structuredContent matches outputSchema; cache fields present |
| Discovery | server/discover from a fresh client | Lists 2026-07-28 and any fallback revisions |
| MRTR | Scripted client | Confirm path completes; tampered, expired or other-user requestState rejected; replay applies no second credit |
| Authorization | Integration tests with tokens of each scope | 401/403 as designed; no cross-tenant access |
| Injection | Adversarial fixtures in invoice memos | No change in tool behaviour |
| Host compatibility | [List of hosts] | Tools usable end to end |
13. Glossary and references
| Term | Meaning |
|---|---|
| Host | The AI application that embeds an MCP client and connects to servers |
| MRTR | Multi round-trip requests: the server answers with a request for input and the client retries with the answers |
requestState | Opaque server data the client echoes back on a retry |
| CacheableResult | Result type carrying ttlMs and cacheScope |
| Handle | A server-minted identifier passed as a tool argument to carry state between calls |
References (as of October 2026):
- Model Context Protocol specification, revision 2026-07-28, and its changelog: https://modelcontextprotocol.io/specification/2026-07-28/changelog
- MCP multi round-trip requests pattern: https://modelcontextprotocol.io/specification/2026-07-28/basic/patterns/mrtr
- OWASP Top 10 for LLM Applications 2026: https://genai.owasp.org/resource/owasp-genai-llm-top-10-2026/
- OWASP Top 10 for Agentic Applications for 2026: https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/
- RFC 8707, RFC 9207 and RFC 9728 at https://www.rfc-editor.org/
- Related templates: AI Agent Specification (
ai-data/ai-agent-spec), Agent Tool Permission Design (ai-data/agent-tool-permission-design), Agentic Threat Model (ai-data/agentic-threat-model), Tool Catalogue (ai-data/tool-catalogue), Guardrails Specification (ai-data/guardrails-spec), Agent Skill Specification (ai-data/agent-skill-spec).
Standard and licence note
Based on the Model Context Protocol specification, revision 2026-07-28, published at modelcontextprotocol.io; structure and requirement names are summarised in original wording. The security mapping uses the entry IDs and short names of the OWASP Top 10 for LLM Applications 2026 and the OWASP Top 10 for Agentic Applications for 2026 by the OWASP GenAI Security Project (https://genai.owasp.org/), licensed under Creative Commons Attribution-ShareAlike 4.0 (https://creativecommons.org/licenses/by-sa/4.0/); descriptions and controls are original. Because the mapping table adapts the OWASP structure, that adapted structure is shared under CC BY-SA 4.0 and any further adaptation must carry the same licence. Larkspur Billing is fictional. Check the specification and the OWASP lists for the current revision and normative text. Apart from the adapted OWASP structure, this is original text. Template licence: MIT.
Related templates
A2A Agent Card and Interface Specification Template (A2A 1.0)
A2A agent spec: Agent Card fields, skills, bindings, security schemes, operations, task states, parts, push, errors, discovery, example card, conformance
AI & Machine LearningAgent Skill Specification Template (SKILL.md)
Agent Skill spec: activation description, SKILL.md frontmatter, layout, scripts, progressive disclosure budget, versioning, security review, evals
AI & Machine LearningAI Agent Specification Template
Tool-using AI agent spec: scope, autonomy, Article 14 oversight, tools and permissions, guardrails, OWASP ASI and LLM 2026 coverage, evals, cost