Optimizing OpenAPI for MCP
Model Context Protocol (MCP) servers are only as good as the tools they expose. Since Tydli generates these tools directly from your OpenAPI specification, the quality of your spec determines the quality of the AI’s interaction. Here are best practices for optimizing your OpenAPI spec for MCP.1. Operation IDs are Tool Names
Tydli uses theoperationId field to generate the tool name.
- Bad:
get_data(Too generic) - Good:
get_customer_orders(Descriptive) - Best Practice: Use
verb_nounformat (e.g.,list_users,create_ticket).
2. Descriptions are AI Prompts
Thedescription fields (for operations and parameters) are the most important part of your spec. They tell the AI when and how to use the tool.
- Operation Description: Explain what the tool does and any side effects.
- Example: “Searches for products by name or category. Returns a list of matching items with stock levels.”
- Parameter Description: Explain constraints and expected format.
- Example: “The search query string. Minimum 3 characters.”
3. Use Enums for Strict Choices
If a parameter has a fixed set of valid values, useenum. This prevents the AI from hallucinating invalid inputs.
4. Define Schemas Clearly
Usecomponents/schemas to define reusable data structures. Give them meaningful names.
- Why: The AI sees the structure of the input and output. Clear schema names help it understand the data model.
5. Prune Unnecessary Endpoints
Don’t expose every internal API endpoint. Only include tools that are useful for the AI.- Tip: Create a specific OpenAPI spec just for your MCP server, removing admin-only or irrelevant endpoints.
6. Security Schemes
Ensure your security schemes are correctly defined so Tydli can handle authentication automatically.Checklist
- Every operation has a unique, descriptive
operationId. - Every operation has a clear
summaryanddescription. - All parameters have
descriptions explaining their purpose. - Enums are used where appropriate.
- Input/Output schemas are well-defined.