Markdown Editor

MCP Server Specification Template (Model Context Protocol)

Transport, discovery, capabilities, tools, CacheableResult, MRTR confirmation and requestState, OAuth, OWASP 2026 mapping, errors, tests

AI & Machine LearningFullModel Context Protocol specification, revision 2026-07-28; OWASP Top 10 for LLM Applications 2026; OWASP Top 10 for Agentic Applications 2026CC BY-SA 4.0mcpserverspec

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

FieldValue
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 updatedYYYY-MM-DD
Security frameworksOWASP 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

RoleNameDecisionDate
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

VersionDateAuthorChange
0.1YYYY-MM-DD[@name]First draft
Example: 0.2YYYY-MM-DD[@name]Moved user confirmation of credits over 25 USD to an elicitation request (section 6)
1.0YYYY-MM-DD[@name]Approved for production

Contents

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.

ItemValue
Wrapped systemExample: Billing API v4
Intended hostsExample: Support assistant (remote), IDE assistants (local)
UsersExample: Support staff and billing engineers
Data classificationExample: Confidential (customer billing data)
Out of scopeExample: Card data, refunds, account closure, bulk export
DeploymentExample: Remote server behind the company gateway; a local stdio build for development only

2. Transport and protocol

AspectChoice
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
Discoveryserver/discover returns supported versions, capabilities and server identity
Request metadataEach request carries io.modelcontextprotocol/protocolVersion and io.modelcontextprotocol/clientCapabilities in _meta; clients should add io.modelcontextprotocol/clientInfo
Server identityEach 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/discover first as a compatibility probe.
  • Streamable HTTP: validate the Origin header 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 the MCP-Protocol-Version, Mcp-Method and (for tools/call, resources/read, prompts/get) Mcp-Name headers and reject header-body mismatches as a HeaderMismatchError (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

CapabilityDeclaredNotes
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 featuresNot usedRoots, 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 capabilityUsed forBehaviour if absent
elicitationExample: 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

IDNameTitleSide effectsreadOnlyHintdestructiveHintidempotentHintopenWorldHint
TL-001 (Example)get_invoiceGet invoiceNonetruen/an/afalse
TL-002 (Example)search_invoicesSearch invoicesNonetruen/an/afalse
TL-003 (Example)apply_creditApply account creditWrites a ledger entryfalsefalsetrue (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 templateNameMIME typeDescriptionttlMscacheScope
billing://policy/creditsExample: Credit policytext/markdownCurrent credit rules3,600,000public
billing://invoices/{invoice_id}Example: Invoiceapplication/jsonOne invoice60,000private

5.2 Prompts

NameArgumentsPurpose
explain_invoiceExample: 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.

ResultttlMscacheScopeReason
tools/listExample: 300,000privateTool visibility depends on the token's scopes (section 7)
prompts/listExample: 3,600,000publicSame for every user
resources/read of an invoiceExample: 60,000privateUser-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.

IDRequestWhen input is requiredInput requestedFallback if the client lacks the capability
MR-001 (Example)tools/call apply_creditAmount over 25 USDForm elicitation: confirm amount and reasonisError: true, "confirmation required, amount over 25 USD"
[MR-nnn][Request][Condition][Input][Fallback]

requestState controls (the specification treats it as attacker-controlled input):

ControlDesign
IntegrityExample: AEAD-encrypted with a key held in the secrets manager, rotated every [90] days
Principal bindingExample: Contains the authenticated user ID; rejected if presented by another user
ExpiryExample: 5 minutes
Request bindingExample: Method name plus a digest of account_id, amount_usd and idempotency_key
Single useExample: 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

AspectDesign
ModelMCP server acts as an OAuth 2.1 resource server
Protected Resource MetadataExample: https://mcp.larkspur.example/.well-known/oauth-protected-resource (RFC 9728) listing the authorization server
Authorization serverExample: Corporate identity provider with RFC 8414 or OpenID Connect discovery; includes iss in authorization responses (RFC 9207)
Client registrationClient ID Metadata Documents preferred; pre-registration for internal hosts; Dynamic Client Registration only for compatibility (deprecated in 2026-07-28)
Token validationAudience must be this server's canonical URI (RFC 8707 resource indicator); reject other tokens; no token passthrough to the billing API
ScopesExample: invoices:read, credits:write; 401 and 403 responses carry the required scope in WWW-Authenticate
Tool visibilityExample: tools/list returns apply_credit only to tokens with credits:write
Downstream callsExample: 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

IDConcernControlTest
MS-01User consent before state changesWrite tools marked readOnlyHint: false; confirmation through MRTR elicitation over 25 USD (section 6); server enforces limits regardlessHost test and MRTR replay test
MS-02Least privilegeSeparate scopes for read and write; service account limited to the credit endpointScope test matrix
MS-03Input validationJSON Schema validation plus business checks (account ownership, daily cap of [200] USD per agent)Unit and fuzz tests
MS-04Untrusted content in resultsInvoice memo fields returned as data in structuredContent; no instructions in tool descriptions that depend on returned textInjection test set
MS-05Rate limitingExample: 30 tools/call per minute per userLoad test
MS-06Output sanitisationCard numbers masked; no secrets in results or errorsSnapshot tests
MS-07DNS rebinding (HTTP)Origin validation; localhost binding for local modeIntegration test
MS-08Sensitive headersNo secrets or personal data in x-mcp-header parametersCode review
MS-09Tampered or replayed requestStateAEAD, principal, expiry and request binding (section 6)Tamper and replay tests
MS-10Supply chainPinned SDK version, signed release, SBOM published with each versionDependency scan in CI
MS-11Hidden context exposureTool descriptions and errors hold no internal hostnames, keys or policy thresholds beyond what the model needsDescription 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 IDRiskControls in this serverHandled elsewhere
LLM01:2026Prompt InjectionMS-04, MS-11Host input guardrails
LLM02:2026Sensitive Information DisclosureMS-02, MS-06, private cache scopeData classification policy
LLM03:2026Excessive AgencyMS-01, MS-02, MS-03Agent tool permission design
LLM04:2026Supply ChainMS-10AI bill of materials
LLM06:2026Unbounded ConsumptionMS-05Gateway quotas
LLM08:2026Hidden Context ExposureMS-11Prompt specification
LLM10:2026Improper Output HandlingMS-06, structuredContent with schemaHost rendering
ASI02Tool Misuse and ExploitationMS-01, MS-03, MS-05Agent tool permission design
ASI03Identity and Privilege AbuseSection 7 audience check, no token passthrough, MS-09Identity provider policies
ASI04Agentic Supply Chain VulnerabilitiesMS-10, pinned server version in the host registryTool 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

SituationResponse
Unknown tool, malformed request, resource not foundJSON-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 missingMissingRequiredClientCapability, code -32021
Unsupported protocol versionUnsupportedProtocolVersionError, code -32022, listing supported versions
Validation or business rule failureTool result with isError: true and an actionable message, for example "amount_usd must be 50 or less"
Backend unavailableTool result with isError: true, "billing service unavailable, retry later"
Expired or invalid requestState or handleisError: 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.]

SignalContentDestinationRetention
Trace span per requestMethod, tool name, result type, latency, error codeExample: OpenTelemetry collector30 days
Audit event per writeUser, account (hashed), amount, reason, idempotency key, outcomeExample: Append-only audit store7 years
Client-visible log messagesOnly when the request's _meta sets io.modelcontextprotocol/logLevelResponse stream of that requestNone 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].
  • listChanged notifications are sent through subscriptions/listen when 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 featureUsed by this serverPlan
Roots, Sampling, LoggingExample: NoNot adopted
Dynamic Client RegistrationExample: Yes, for one legacy hostMove host to Client ID Metadata Document by YYYY-MM-DD

12. Testing

TestToolPass criteria
Interactive checkMCP Inspector (npx @modelcontextprotocol/inspector)All tools, resources and prompts listed and callable with valid inputs
Schema conformanceContract tests against the published schemaAll results validate; resultType present; structuredContent matches outputSchema; cache fields present
Discoveryserver/discover from a fresh clientLists 2026-07-28 and any fallback revisions
MRTRScripted clientConfirm path completes; tampered, expired or other-user requestState rejected; replay applies no second credit
AuthorizationIntegration tests with tokens of each scope401/403 as designed; no cross-tenant access
InjectionAdversarial fixtures in invoice memosNo change in tool behaviour
Host compatibility[List of hosts]Tools usable end to end

13. Glossary and references

TermMeaning
HostThe AI application that embeds an MCP client and connects to servers
MRTRMulti round-trip requests: the server answers with a request for input and the client retries with the answers
requestStateOpaque server data the client echoes back on a retry
CacheableResultResult type carrying ttlMs and cacheScope
HandleA server-minted identifier passed as a tool argument to carry state between calls

References (as of October 2026):

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