DRAFT: consider adding REST method annotations for things #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SEP: REST Endpoint Type Hints for Resources
Title: REST Endpoint Type Hints for Resources
Author: Tapan Chugh (@chughtapan)
Status: Proposal
Type: Standards Track
Created: 2025-01-24
Abstract
This SEP proposes optional type hints for MCP resources to indicate REST endpoint semantics, including HTTP methods and request body schemas. These hints enable servers to expose existing REST APIs as MCP resources without requiring complete reimplementation, addressing the inefficiencies of current REST-to-MCP conversion approaches while maintaining full backward compatibility.
Motivation
Current approaches to exposing REST APIs through MCP face significant challenges:
Conversion Overhead: As noted in "Stop Converting Your REST APIs to MCP", auto-converting REST APIs to MCP tools creates context pollution, excessive token consumption, and overwhelms agents with too many endpoint choices.
Loss of Semantics: REST's HTTP method semantics (GET, POST, PUT, DELETE) are lost when converting to MCP's method-agnostic resources, requiring workarounds like encoding operations in URIs.
Reimplementation Burden: The vast amount of existing REST API code makes rewriting from scratch impractical. Resources provide a natural mapping to REST endpoints but currently lack the ability to express HTTP methods and request bodies.
Bootstrap Barrier: Developers need a way to quickly expose existing REST APIs for initial exploration and prototyping before investing in curated, agent-optimized interfaces.
This proposal addresses these issues by allowing resources to optionally declare REST semantics, enabling:
Specification
This proposal extends the MCP specification with optional REST type hints for resources:
1. New Type Definition
2. Extended Resource Annotations
3. Updated Resource Interfaces
The
ResourceandResourceTemplateinterfaces useResourceAnnotationsinstead of the baseAnnotationstype.4. Elicitation Flow for REST Resources
When reading a resource with
requestBodySchema:resources/readrequestelicitation/createto gather request body dataRationale
Design Decisions
Optional Annotations: All REST hints are optional to ensure 100% backward compatibility. Existing resources continue to work unchanged.
Reuse Elicitation: Rather than creating a new mechanism for request bodies, we reuse the existing elicitation system, maintaining consistency with the protocol.
Resources over Tools: While REST endpoints could be exposed as tools, resources provide better semantic alignment with REST's resource-oriented architecture and URI-based identification.
Limited Schema Complexity: Request body schemas use the same restricted format as elicitation (flat objects with primitive types) to maintain simplicity and ensure broad client support.
Alternatives Considered
Automatic Tool Generation: Current approaches like FastMCP convert REST endpoints to tools, but this loses REST semantics and creates the context pollution issues described in the motivation.
New Protocol Extension: A separate REST-specific protocol extension would add complexity without leveraging existing MCP concepts.
Complex Schemas: Supporting nested objects in request bodies was considered but would complicate implementation and diverge from existing elicitation patterns.
Backward Compatibility
This proposal maintains full backward compatibility:
requestBodySchemais presentReference Implementation
A reference implementation would include:
Security Implications
Examples
GET Resource
{ "uri": "https://api.example.com/users/123", "name": "Get User", "mimeType": "application/json", "annotations": { "httpMethod": "GET" } }POST Resource with Request Body
{ "uri": "https://api.example.com/users", "name": "Create User", "mimeType": "application/json", "annotations": { "httpMethod": "POST", "requestBodySchema": { "type": "object", "properties": { "name": { "type": "string", "description": "User's name" }, "email": { "type": "string", "format": "email", "description": "User's email address" } }, "required": ["name", "email"] } } }Resource Template with REST Hints
{ "uriTemplate": "https://api.example.com/users/{id}", "name": "Update User", "mimeType": "application/json", "annotations": { "httpMethod": "PUT", "requestBodySchema": { "type": "object", "properties": { "name": { "type": "string", "description": "Updated name" }, "email": { "type": "string", "format": "email", "description": "Updated email" } } } } }Conclusion
This proposal provides a pragmatic bridge between the existing REST API ecosystem and MCP, enabling developers to:
By making REST hints optional, we maintain MCP's flexibility while providing a clear path for REST API integration.