inspector icon indicating copy to clipboard operation
inspector copied to clipboard

Resource template query parameters not appended to request URI

Open culumn opened this issue 7 months ago • 0 comments

Describe the bug
When reading a resource template, the request URI is constructed incorrectly, causing query parameters not to appear as expected.

Image Image

To Reproduce

  1. Prepare a MCP server that implements a resource template with query parameters. In this example, the template URI is defined as app://users{?name}.
  2. Launch the Inspector and start the mcp server.
  3. Select the resource template.
  4. Enter a value for the name query parameter (e.g., foo).
  5. Click the Read Resource button to send the request to the MCP server.
  6. Observe that the request fails because the constructed URI is invalid. For example, you will see app://usersfoo instead of including ?name=foo.

Expected behavior
The query parameters should be appended correctly. In this example, the request URI should be app://users?name=foo.

Additional context
I believe the issue originates from the lines below in ResourcesTab.tsx (commit ec24f7b):
https://github.com/modelcontextprotocol/inspector/blob/ec24f7bbbf1535084c5f03157c80eceb4e79278d/client/src/components/ResourcesTab.tsx#L78-L86

It may be helpful to leverage the UriTemplate class from the TypeScript SDK, which already handles URI templates correctly:
https://github.com/modelcontextprotocol/typescript-sdk/blob/main/src/shared/uriTemplate.test.ts

culumn avatar May 27 '25 11:05 culumn