Guides creation of high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools...
Create MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. The quality of an MCP server is measured by how well it enables LLMs to accomplish real-world tasks.
Creating a high-quality MCP server involves four main phases:
API Coverage vs. Workflow Tools: Balance comprehensive API endpoint coverage with specialized workflow tools. When uncertain, prioritize comprehensive API coverage.
Tool Naming and Discoverability:
Use consistent prefixes (e.g., github_create_issue, github_list_repos) and action-oriented naming.
Context Management: Design tools that return focused, relevant data. Support filtering/pagination.
Actionable Error Messages: Error messages should guide agents toward solutions with specific suggestions.
Start with the sitemap: https://modelcontextprotocol.io/sitemap.xml
Fetch pages with .md suffix (e.g., https://modelcontextprotocol.io/specification/draft.md).
Key pages: Specification overview, transport mechanisms, tool/resource/prompt definitions.
Recommended stack:
Load framework documentation:
SDK Documentation:
https://raw.githubusercontent.com/modelcontextprotocol/typescript-sdk/main/README.mdhttps://raw.githubusercontent.com/modelcontextprotocol/python-sdk/main/README.mdReview the service's API documentation. List endpoints to implement, starting with most common operations.
See language-specific guides:
Create shared utilities:
For each tool:
Input Schema:
Output Schema:
outputSchema where possiblestructuredContent in responsesTool Description:
Annotations:
readOnlyHint, destructiveHint, idempotentHint, openWorldHintReview for: DRY principle, consistent error handling, full type coverage, clear descriptions.
TypeScript:
npm run build
npx @modelcontextprotocol/inspector
Python:
python -m py_compile your_server.py
# Test with MCP Inspector
Create 10 evaluation questions to test LLM effectiveness with your server.
Requirements for each question:
Output Format:
<evaluation>
<qa_pair>
<question>Your question here</question>
<answer>Expected answer</answer>
</qa_pair>
</evaluation>
See Evaluation Guide for complete guidelines.
FastMCP validates Host headers. For Docker, configure:
from mcp.server.fastmcp import FastMCP
from mcp.server.transport_security import TransportSecuritySettings
transport_security = TransportSecuritySettings(
allowed_hosts=[
"127.0.0.1:*", "localhost:*", "[::1]:*",
"mcp-server:*", # Docker container name
"0.0.0.0:*",
],
)
mcp = FastMCP("my_server", transport_security=transport_security)
Add /health endpoint via middleware (see references for full example).
Run: python3 scripts/verify.py
Expected: ✓ building-mcp-servers skill ready