MCP Builder Tools
MCP Builder Tools provide utilities and helpers for building robust MCP servers with FastMCP. These tools simplify common patterns and ensure best practices.Tool Registration
register_all_tools
Register all available tools with an MCP server.Selective Registration
Register only specific tool categories:Credential Management
CredentialStoreAdapter
Manage credentials from multiple sources.Credential identifier
CredentialSpec
Define credential specifications for tools.Validation
Tool Decorators
@mcp.tool()
Basic tool registration:Type Hints
Use Python type hints for automatic parameter validation:Error Handling Patterns
Standard Error Response
Retry Logic
Testing Utilities
Tool Testing
Integration Testing
Custom Routes
Adding HTTP Endpoints
Logging
Structured Logging
Performance Optimization
Connection Pooling
Caching
Best Practices
Tool Naming
Tool Naming
- Use snake_case:
my_tool, notmyTool - Be descriptive:
search_github_repos, notsearch - Group related tools:
github_*,slack_* - Avoid abbreviations unless very common
Documentation
Documentation
- Write clear docstrings for every tool
- Document all parameters with types and constraints
- Include examples in docstrings
- Provide error handling guidance
- Maintain README.md for each tool
Error Messages
Error Messages
- Be specific: “Query must be 1-500 characters”, not “Invalid query”
- Include help text:
{"error": "...", "help": "Get API key at..."} - Add error codes for programmatic handling
- Suggest remediation steps
Testing
Testing
- Test all parameters and edge cases
- Mock external APIs
- Test error handling paths
- Test with real credentials (in separate suite)
- Use CI/CD for automated testing
Next Steps
Creating Tools
Build custom tools for your use case
MCP Server Setup
Deploy your MCP server