Skip to content

Decode resource template parameters #91

@andriy-dmytruk

Description

@andriy-dmytruk

Expected Behavior

Suppose I have the following definition:

    @ResourceTemplate(
            uriTemplate = "book://book/{title}",
            mimeType = "text/plain",
            name = "book",
            title = "Library Book Description",
            description = "Provide description about a book"
    )
    String getBookDescription(String title) {
        return bookService.get(title)
                .orElseThrow(() -> new McpError(new McpSchema.JSONRPCResponse.JSONRPCError(
                        McpSchema.ErrorCodes.RESOURCE_NOT_FOUND,
                        "resource for title " + title + " not found",
                        null
                )));
    }

Title might contain spaces and therefore will be URL-encoded. The parameter needs to be provided in a URL-decoded format.

Actual Behaviour

I get the following error:

{
"error":
"MCP error -32001: Error POSTing to endpoint (HTTP 500): {"jsonrpc":"2.0","id":19,"error":{"code":-32002,"message":"resource for title A%20Tale%20of%20Two%20Cities not found"}}"
}

Steps To Reproduce

No response

Environment Information

No response

Example Application

No response

Version

0.0.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions