MCP Server Design Guide — Build Custom AI Agent Tools¶
Model Context Protocol (MCP) servers extend Hermes Agent with custom tools and data sources. Designing an MCP server well means respecting both the protocol constraints and the expectations of the Hermes community. This MCP server design guide covers tool design, error handling, performance, testing, and the full server lifecycle.
Overview¶
MCP servers are how Hermes Agent connects to external systems. Each server exposes tools — typed, documented functions that the agent can call. Following MCP design best practices ensures your server is reliable, performant, and easy for the community to adopt.
How It Works¶
When to Build vs When to Buy¶
Build when: No existing MCP server exists for your data source, you need custom behavior, strict security demands self-hosting, or you're integrating an internal system.
Use existing when: It covers your use case and is actively maintained. Search the MCP ecosystem and skills catalog first.
Avoid building when: A simple REST API call from a skill would work. Not every integration needs an MCP server.
Tool Design Principles¶
| Principle | Good | Bad |
|---|---|---|
| One tool, one responsibility | get_customer_profile, get_customer_billing |
get_customer_data (does everything) |
| Descriptive names | list_recent_orders |
get_data |
| Pagination by default | Always include limit/offset |
Unbounded responses |
| Consistent errors | {code, message, retry_after} |
Raw upstream errors |
| Filter parameters | list_users(role="admin", status="active") |
No filter support |
Error Handling¶
- Timeouts: Configurable per tool; retry transient failures with backoff
- Graceful degradation: Return partial results with caveats when upstream is partially down
- Rate limit awareness: Track upstream limits; return clear
retry_afterguidance - Pre-validation: Validate parameters before upstream calls to save round trips
Performance¶
- Connection pooling: Reuse HTTP connections (saves 100-300ms per call)
- Response size discipline: Filter and limit at server level
- Bulk operations: Provide batch endpoints for multi-record operations
- Caching with care: Document freshness guarantees
Server Lifecycle¶
Development → Beta (real creds, limited access, 1+ week monitoring) → Production (full monitoring, stable schemas) → Maintenance (upstream API updates, deprecation with 30+ day notice) → Sunset
Benefits¶
- Extensible agent capabilities: Every MCP server adds new tools Hermes Agent can use
- Community leverage: Hundreds of existing MCP servers cover common integrations
- Type safety: Structured tool schemas mean reliable parameter passing
- Reusable across agents: One MCP server works with any MCP-compatible agent
FAQ¶
Do I need to build an MCP server for every API integration?¶
No. If the integration is a single API call with simple parameters, a skill step is simpler. Build an MCP server when you need multiple tools, state management, authentication handling, or want to share with the community.
How do I handle pagination in MCP server tools?¶
Always support limit/offset or cursor-based pagination for any tool that can return more than 50 items. Return pagination metadata (total count, next cursor) so callers know when more data is available.
How do I test an MCP server before publishing?¶
Validate schema compliance with the MCP validator. Unit test each tool with valid/invalid inputs and edge cases. Integration test against a sandbox environment. Performance test typical queries. Complete a security review for credential exposure and data logging.
Related Pages¶
- Best Practices Overview — All guides
- MCP Integration Guide — Connect existing MCP servers
- Skill Development — Skills that call MCP tools
- Security — Secure MCP server auth patterns
- Creating Custom Skills — When skills are better than MCP servers
Good tools compose. Great tools compose predictably.