Model Context Protocol Best Practices for Reliable Tools
The Model Context Protocol lets models call tools and read resources through one standard. These practices cover tool design, resources, sampling and security.
On this page
Short answer
The Model Context Protocol works best when tools are named clearly with strict input schemas, resources are addressed by stable URIs, and prompts are versioned like code. Keep the protocol surface small, validate every input, and test the full client-server flow before you let a model use it in production.
What is the Model Context Protocol?
The Model Context Protocol, or MCP, is an open standard that lets an AI model connect to outside tools and data through a common interface. Instead of building a custom integration for each tool, a client speaks MCP and any MCP server can plug in.
MCP defines a small set of building blocks. Tools are functions the model can call, such as searching a database or filing a ticket. Resources are data the model can read, such as files or records addressed by a URI. Prompts are reusable templates, and sampling lets a server ask the model to generate text.
| Building block | What it does | Who defines it |
|---|---|---|
| Tools | Actions the model can call | Server |
| Resources | Data the model can read | Server |
| Prompts | Reusable instruction templates | Server |
| Sampling | Model text generation on request | Client |
The point of the standard is that the model, the client and the server agree on how to talk, so a tool built once works with many models. For the basics, see what the Model Context Protocol is.
How do you design tools a model can use well?
You design tools a model can use well by giving each tool one clear job, a plain-language name and a strict input schema. A model chooses tools from their names and descriptions, so vague tools get misused.
Name tools with verbs and objects, such as search_orders or create_ticket, and write a description that says what the tool does, when to use it and what it returns. Avoid names that overlap: if two tools sound similar, the model will pick the wrong one.
Keep the input schema tight. Mark required fields, give each field a clear description and a type, and reject extra fields. A loose schema invites the model to invent arguments, which leads to errors that are hard to trace.
Return structured results with a clear status. A tool that returns a short summary plus the raw fields lets the model quote facts without guessing, and an error message that says what went wrong lets the model recover or ask the user.
How should you expose resources?
You should expose resources through stable, readable URIs that tell the model what the data is and where it came from. A resource that is hard to address is a resource the model will not use well.
Use a scheme that names the source, such as docs://handbook/expenses or crm://accounts/1042, and keep the URI stable over time. If a URI changes every week, links in old conversations break and the model cannot learn which resources are reliable.
Expose the smallest useful unit. A resource that returns an entire 200-page handbook forces the model to search through noise; a resource that returns one section is far more useful. Offer listing resources that show what is available, then let the model fetch the exact item.
Mark sensitive resources clearly and require the same permissions a human would need. A resource that exposes private data to any client is a security hole, not a feature.
How do you handle prompts and sampling?
You handle prompts and sampling by treating prompt templates as versioned code and by keeping sampling requests narrow and supervised. Both features are powerful, and both can surprise you if they are left loose.
Write prompt templates that state the task, the inputs and the expected output format, and keep them short. A template that runs to several pages is hard to review and hard to test. Version each template, and record which version produced each result so a bad change can be rolled back.
Sampling lets a server ask the model to generate text, for example to summarise a document. Ask for small, bounded outputs and validate them before acting on them. A server should never take sampled text and run it as a command without a check.
Log every sampling request with its inputs and outputs. When a result looks wrong, the log is the only way to find out whether the template, the input or the model was at fault.
How do you keep MCP connections secure?
You keep MCP connections secure by authenticating every client, authorising every tool call, and treating tool outputs as untrusted data. A protocol that connects models to real systems needs the same care as any API.
Authenticate the client before it can list tools or read resources, and give each client only the tools it needs. A support client should not be able to call a finance tool, even if the model asks it to.
Validate every tool argument on the server side. The model can send any value, including values that try to break out of their intended use, so the server must check types, ranges and permissions before acting.
Treat tool outputs as data, never as instructions. A document returned by a tool could contain text that tries to make the model take a different action. Keep the model's instructions separate from tool results, and require a human or a policy check before any destructive action.
Example (hypothetical): a support MCP setup
Example (hypothetical): a support team replaces six hand-written connectors with one MCP server that exposes three tools and two resources. Each connector took about 3 days to build, so six connectors took 6 x 3 = 18 days of work. The MCP server took 5 days, saving 13 days.
The server exposes search_tickets, create_ticket and lookup_order tools, plus order and handbook resources. Each tool has a strict schema and returns a short summary with the raw fields, so the model can quote order numbers without guessing.
In the first month, failed tool calls drop from 40 a week to 6 a week. Most of the remaining failures are missing order numbers in the user's message, which the model now asks for instead of guessing.
The team keeps a log of every tool call and reviews the failures weekly. When a new ticket type appears, they add one tool instead of rebuilding an integration, and the change takes an afternoon.
What are the common mistakes?
The most common Model Context Protocol mistakes are vague tools, loose schemas, unversioned prompts and treating tool output as trusted instructions.
- Tools that do too much. A tool called do_everything with ten optional arguments will be misused. Split it into small tools with one job each.
- Loose input schemas. Without required fields and types, the model invents arguments and the server fails in confusing ways.
- Unversioned prompts. Changing a template without a version number makes it impossible to trace a bad result back to its cause.
- Trusting tool output. Text returned by a tool can contain injected instructions. Keep it as data and check it before acting.
- No auth on the server. An MCP server without authentication is an open door to every tool it exposes.
- Exposing everything at once. Listing dozens of tools overwhelms the model. Expose the few it needs for the task at hand.
These mistakes all come from treating MCP as a demo feature rather than a real interface. The same review, testing and access control that apply to any API apply here too.
How do you test and version an MCP setup?
You test and version an MCP setup by keeping a fixed test suite that exercises every tool, resource and prompt, and by versioning the server so a bad release can be rolled back. A protocol setup without tests breaks silently when a tool changes.
Write tests that call each tool with valid inputs, invalid inputs and missing fields, and check that the server returns the right result or a clear error. Add a test for each new tool before it ships, and run the suite on every change.
Version the server and record which client versions work with it. When you change a tool's schema, bump the version and keep the old behaviour available until clients have moved over. Breaking a schema without warning breaks every client at once.
Test the full flow, not just the server. A tool can pass its own tests and still fail when the model calls it with real phrasing, so include a few end-to-end conversations in the suite. For the build steps, see how to implement the Model Context Protocol.
For how the pieces fit together, see how the Model Context Protocol works.
Key takeaways
- MCP gives models one standard way to reach tools and data
- Design each tool for one job, with a clear name and strict schema
- Expose resources through stable URIs at the smallest useful unit
- Authenticate clients, validate inputs and treat tool output as data
- Version prompts and servers, and test the full client-server flow
Frequently asked questions
How is MCP different from a normal API?
A normal API is called by code that knows its exact shape. MCP adds a standard way for a model to discover tools, read their descriptions and call them, plus resources and prompts. The server still does the work, but the model can choose which tool fits the task without custom code for each one.
Can one MCP server work with different models?
Yes, that is the point of the standard. Any client that speaks MCP can connect to any MCP server, so a server built once can serve several models. The server should still be tested with each model, because different models phrase tool calls differently.
How many tools should an MCP server expose?
As few as the task needs, usually under a dozen for one use case. A long list of tools makes it harder for the model to pick the right one and harder for the team to maintain. If a server grows past that, split it by domain so each server stays focused.
Do MCP resources replace retrieval?
No. Resources give the model direct access to specific items, such as a named document or record. Retrieval searches a large collection for the most relevant items. Many setups use both: retrieval to find candidates, then resources to fetch the exact item.
Is MCP secure by default?
No. MCP defines how clients and servers talk, not who is allowed to do what. Authentication, authorisation, input validation and logging are the server's job. A server without them exposes its tools to anyone who can connect.
When should you build an MCP server instead of a custom integration?
Build an MCP server when several models or clients need the same tools, or when the tool set will grow over time. A single custom integration is simpler when only one model needs one tool and the scope will not change.