MCP Server Development
Building MCP servers: tools, resources, prompts, argument schemas, permissions, idempotency and client compatibility.
The Model Context Protocol standardizes how AI applications connect to context and tools. A host holds a client connection to a server that exposes negotiated capabilities. This article uses the MCP specification of 18 June 2025 [1]; an implementation chooses a specific supported version and does not assume that all clients have the same capabilities.
Interaction model
Section titled “Interaction model”MCP uses JSON-RPC 2.0 messages. Initialization and capability negotiation come before working calls. The transport, the connection life cycle and authorization support are checked for every chosen client.
| Primitive | Purpose | Example |
|---|---|---|
| Resources | Addressable context | A document with the terms of a pricing plan |
| Tools | Calling an operation with arguments | Check stock or create a ticket |
| Prompts | A parameterized interaction template | Prepare a report review |
An MCP server is an adapter for a domain API. It must not hide important differences between reading, preliminary calculation and changing data. MCP support does not guarantee that a particular AI client will discover the server or choose the right tool.
The tool contract
Section titled “The tool contract”The description sets the purpose, required fields, units, allowed values, result and errors. For operations with side effects it states the conditions for repeating a call and how to check the state. An ambiguous amount field is replaced by an explicitly defined sum in agreed units, with a currency.
This is a design model of effective permissions: access is limited to the intersection of the rights of the user, the client, the server and the object. A text description of a tool does not replace a server-side check. The right to read an order must not automatically grant the right to issue a refund.
OAuth Security Best Current Practice describes the threats to and requirements for modern OAuth flows [2]. The token audience, scope and expiry are checked regardless of how convincingly the agent phrased its request.
Errors and retries
Section titled “Errors and retries”JSON Schema validation catches errors of form, but it does not guarantee business correctness. The server separately checks that the object exists, its current status and whether the transition is allowed. Transport, protocol and domain errors must be distinguishable, so that the client does not blindly repeat an irreversible action.
For an operation key , is enforced. If the client lost the response, it asks for the status or repeats the request under an idempotent contract. Rate limits and timeouts return a clear result and do not reveal secrets in diagnostics.
Untrusted context
Section titled “Untrusted context”Research on indirect prompt injection shows that instructions can reach a model through retrieved documents [3]. So the contents of a resource or the response of an external API gain no authority to change the system’s rules. Permissions, address restrictions and argument checks must be enforced outside the model.
Compatibility testing
Section titled “Compatibility testing”The test matrix covers the client, protocol version, transport, authorization, available primitives and real scenarios. Empty responses, large results, cancellation, retries, an expired token and access denied to a specific object are tested.
The main task metric is reaching the expected state while respecting the constraints. The share of successfully parsed JSON is only a technical indicator. The trace stores the call ID, schema version, duration, status and a link to the confirmed result; sensitive fields are redacted before they are written to the log.
Reproducibility and how Answerwell applies it
Section titled “Reproducibility and how Answerwell applies it”In the project’s research loop, Answerwell’s own robots and ML/DL models are applied to brand data. The grounds for each architecture, corpus versions, training parameters and compute are recorded according to the general methodology. Public, acquired and internal data each keep their own provenance; describing a method does not mean a proven match with the closed weights of an external platform.
The test set is separated from training by time and by object. Raw observations, failed attempts and unknown values are kept. Models are compared on the same data and budget, with the sample size and errors by segment reported. Illustrative calculations in this article are not a claim about an experiment Answerwell has carried out.
Sources
Section titled “Sources”- MCP contributors (2025-06-18). Model Context Protocol specification.
- Lodderstedt T. et al. (2025). RFC 9700: Best Current Practice for OAuth 2.0 Security.
- Greshake K. et al. (2023). Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection.