The original implementation had several issues with the MCP resource specification:
- Wrong method name: Used
resources/getinstead ofresources/read - Wrong parameter name: Used
nameinstead ofurifor resource requests - Incorrect response structure: The response format didn't match the MCP specification
- Missing URI handling: Resources weren't properly identified with URIs
Before:
{
"resources": [
{
"name": "resource_name",
"description": "description",
"inputSchema": {
"type": "object",
"properties": {}
}
}
]
}After:
{
"resources": [
{
"uri": "file://resource_name",
"name": "resource_name",
"description": "description",
"mimeType": "application/json"
}
]
}Updated the method handler to use the correct MCP specification method name.
Before: Used name parameter
{
"params": {
"name": "resource_name"
}
}After: Uses uri parameter
{
"params": {
"uri": "file://resource_name"
}
}Before:
{
"content": [
{
"type": "resource",
"resource": {
"uri": "data:mime/type;base64,content",
"mimeType": "mime/type",
"text": "content"
}
}
],
"isError": false
}After:
{
"contents": [
{
"uri": "file://resource_name",
"mimeType": "mime/type",
"text": "content" // for text content
// OR
"blob": "base64_encoded_content" // for binary content
}
]
}- Proper URI handling: Resources are now identified by URIs (
file://resource_name) - Correct method names: Uses
resources/readinstead ofresources/get - Specification-compliant responses: Response format matches the official MCP specification
- Better MIME type detection: Improved automatic MIME type detection for resources
- Cleaner binary/text handling: Separate fields for text (
text) and binary (blob) content
- Standards compliance: Now fully compliant with MCP 2024-11-05 specification
- Better interoperability: Works correctly with MCP clients expecting standard responses
- Cleaner API: More intuitive URI-based resource identification
- Improved content handling: Better separation of text and binary content
These changes ensure that the MCP server now correctly implements the resource specification and will work properly with standard MCP clients.