The MCP (Model Context Protocol) Server handler supports tools, enabling you to expose your API routes as executable functions that AI clients can call to perform actions or retrieve data.
Tools are the core building block of MCP servers, allowing AI systems to interact with your services and discover capabilities through your Zuplo gateway.
Overview
Zuplo's MCP tools work by automatically transforming your API routes into MCP tool definitions. When an AI client calls a tool, the MCP server invokes the corresponding route handler in your gateway.
This means any existing API route can be instantly turned into an MCP tool with minimal configuration.
Configuration
Route Configuration
Configure a route in your OpenAPI doc:
Code
To provide MCP specific metadata for the tool, use the mcp property within
x-zuplo-route:
The x-zuplo-route.mcp configuration for tools supports:
type: Set to"tool"(optional, as this is the default)name(optional) - The identifier for the MCP tool. Defaults to the operation'soperationId.description(optional) - Description of what the tool does. Falls back to the operation'sdescriptionorsummary.enabled(optional) - Whether this tool is enabled. Defaults totrue.
The route handler for your tool is any standard Zuplo request handler like the URL Fowarder or the Redirect handler or a custom function module. The route receives the request triggered by the MCP tool call within the gateway and returns a response that will be passed back through the MCP server to the AI client.
MCP Server Handler Configuration
Add tool configuration to your MCP Server handler options using the operations
array:
Code
The operations array supports:
file- Path to the OpenAPI specification file containing tool routesid- The operation ID to include as an MCP tool
Route Handler Implementation
Testing MCP Tools
List Available Tools
Use the MCP tools/list method to see available tools:
Code
Response:
Code
Call a Tool
Use the MCP tools/call method to execute a tool:
Code
Response:
Code
Tool names and descriptions
MCP tools are configured as follows:
- Tool names: Uses the route's
operationIdif available, otherwise falls back to a generatedMETHOD_ROUTEformat (for example,GET_todos) - Tool descriptions: Derived from (in order of priority):
- The route's
descriptionfield - The route's
summaryfield - A generated description if neither is available
- The route's
Best Practice: Always set meaningful operationIds (like get_users,
create_new_deployment, or update_shopping_cart) and descriptions as these
help LLMs understand exactly what each tool does.
Read more about authoring usable tools and good prompt engineering practices with Anthropic's Prompt engineering overview.
Best Practices
Tool Descriptions
AI models rely heavily on tool descriptions to understand when and how to use a tool.
- Be Descriptive: Explain exactly what the tool does and what inputs it expects.
- Use Meaningful Names: Operation IDs like
create_userorsearch_productsare much better thanop1orendpoint.
Input Validation
Define clear schemas in your OpenAPI document. The MCP server uses these schemas to validate arguments provided by the AI client before your handler is ever called. This ensures your handler receives valid data.
Custom Tools
For complex workflows that don't map 1:1 to a single API route, or require advanced logic, consider using Custom MCP Tools.