| title | MCP Tool Skill Template |
| slug | skill-template-mcp |
| status | living |
| last_updated | 2025-11-01 |
| last_synced | 2025-11-01 |
| tags | catalog, skill, mcp |
| summary | Template for documenting MCP-backed skills, including contracts, procedures, and fallbacks. |
| authors | |
| sources | |
| name | <skill-name> |
| description | MCP tool wrapper for <tool-purpose>. Replace this with your tool's description. |
| iface | [object Object] |
| mcp | [object Object] |
| slo | [object Object] |
| limits | [object Object] |
()
For Humans: Use this template when wrapping MCP tools as catalog skills.
For AI Agents: Populate every field, validate contracts, and document fallback logic.
Purpose
MCP Tool Template provides a standardized structure for creating skills that wrap Model Context Protocol (MCP) tools. This template demonstrates how to integrate external MCP servers into the MAGSAG framework while maintaining contract validation, error handling, and observability requirements.
When to Use
- You need to integrate an external MCP tool as a reusable skill
- The MCP server source lives in
ops/adk/servers/<server-id>.yamland produces.mcp/servers/<server-id>.json - Input and output data structures are defined via JSON Schema contracts
- The tool will be invoked by agents or other orchestration workflows
Prerequisites
- MCP server configured via
ops/adk/servers/<server-id>.yamland regenerated to.mcp/servers/<server-id>.json - Input schema defined at
catalog/contracts/<input-contract>.json - Output schema defined at
catalog/contracts/<output-contract>.json - Environment variables required by the MCP server (if any) are set
- Rate limits configured in the MCP server configuration
Procedures
Procedure 1: Invoke MCP Tool
- Validate Input - Ensure the input payload conforms to the input schema contract
- Prepare Request - Extract relevant fields from the payload and format them for the MCP tool
- Call MCP Tool - Invoke the MCP server tool with prepared arguments
- Handle Response - Process the MCP tool response and transform it to match the output schema
- Error Handling - Catch and handle common errors (rate limits, timeouts, validation failures)
- Validate Output - Ensure the output conforms to the output schema contract
Procedure 2: Fallback Behavior
- If the MCP tool is unavailable, return a structured error response
- Log the failure with appropriate context for debugging
- Consider returning cached results if applicable
- Emit warnings when operating in degraded mode
Examples
Example 1: Basic Tool Invocation
- Input: resources/examples/in.json
- Process:
- Validate input against schema
- Call MCP tool with extracted parameters
- Transform response to output format
- Validate output against schema
- Output: resources/examples/out.json
Update Log
- 2025-11-01: Added unified frontmatter and audience guidance to the MCP skill template.
Implementation Notes
File Structure
<skill-name>/
├── SKILL.md # This file
├── impl/
│ └── mcp_tool.py # Tool implementation
├── resources/
│ └── examples/
│ ├── in.json # Sample input
│ └── out.json # Sample output
└── tests/
└── test_mcp_tool.py # Unit tests
Key Functions
async def run(payload: dict[str, Any], *, mcp: Optional[MCPRuntime] = None) -> dict[str, Any]– Main entry point with optional MCP runtime_validate(payload: dict[str, Any], schema: dict[str, Any], name: str) -> None– Input/output validation helper_prepare_request(payload: dict[str, Any]) -> dict[str, Any]– Request transformation helperasync def _call_mcp_tool(**kwargs) -> Any– Local or mocked execution path when MCP runtime is unavailableasync def _call_tool_via_runtime(mcp: MCPRuntime, request: dict[str, Any]) -> Any– Preferred MCP runtime integration path_process_response(raw_response: Any, payload: dict[str, Any]) -> dict[str, Any]– Response normalization helper
Development Checklist
- Copy template to
catalog/skills/<your-skill-name>/ - Update
name,description, andmcp.server_refin SKILL.md frontmatter - Define input/output contracts in
catalog/contracts/ - Implement
_call_mcp_tool()inimpl/mcp_tool.py - Create example payloads in
resources/examples/ - Write tests in
tests/test_mcp_tool.py - Run
mypy --strictandruffto ensure code quality - Run
pytestto verify all tests pass - Register skill in
catalog/registry/skills.yamlif needed
Additional Resources
.mcp/README.md- MCP server configuration guidedocs/guides/agent-development.md- Skill development guidelines- MCP Official Documentation: https://modelcontextprotocol.io/
Troubleshooting
- MCP Server Not Found: Verify
ops/adk/servers/<server-id>.yamlexists and.mcp/servers/<server-id>.jsonis up to date - Rate Limit Exceeded: Check the
limits.rate_per_minsetting in SKILL.md and MCP server config - Schema Validation Errors: Ensure contracts match actual payload structure
- Timeout Errors: Increase latency threshold or optimize MCP tool query
- Missing Environment Variables: Check MCP server requirements in
.env.example