Title: Resource template parameters do not support values with slashes · Issue #159 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Resource template parameters do not support values with slashes · Issue #159 · modelcontextprotocol/python-sdk
X Title: Resource template parameters do not support values with slashes · Issue #159 · modelcontextprotocol/python-sdk
Description: Describe the bug Overview Resource template values containing path separators (slashes) do not work. Working Examples Simple Static Resources @mcp.resource("resource://my-resource") def get_data() -> dict[str, Any]: return { "contents": ...
Open Graph Description: Describe the bug Overview Resource template values containing path separators (slashes) do not work. Working Examples Simple Static Resources @mcp.resource("resource://my-resource") def get_data() ...
X Description: Describe the bug Overview Resource template values containing path separators (slashes) do not work. Working Examples Simple Static Resources @mcp.resource("resource://my-resource") def g...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/159
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Resource template parameters do not support values with slashes","articleBody":"**Describe the bug**\n\n## Overview\nResource template values containing path separators (slashes) do not work.\n\n## Working Examples\n\n### Simple Static Resources\n```python\n@mcp.resource(\"resource://my-resource\")\ndef get_data() -\u003e dict[str, Any]:\n return {\n \"contents\": [{\n \"uri\": \"resource://my-resource\",\n \"mimeType\": \"text/plain\",\n \"text\": \"Hello, world!\"\n }]\n }\n```\nThis works reliably and shows up in the Inspector UI.\n\n### Parameter \n```python\n@mcp.resource(\"resource://{value}\")\ndef get_content(value: str) -\u003e dict[str, Any]:\n # This works for: resource://\n # But fails for: resourse://value/with/slashes\n ...\n```\n\n**To Reproduce**\n\n### 1. Template Pattern with Regex\n```python\n@mcp.resource(\"resource://{value:.*}\")\ndef get_content(value: str) -\u003e dict[str, Any]:\n # Error: Mismatch between URI parameters set() and function parameters {'permalink'}\n```\n\n### 2. Generic Catch-all Pattern\n```python\n@mcp.resource(\"memory://*\")\ndef get_content(uri: str) -\u003e dict[str, Any]:\n # Error: Mismatch between URI parameters set() and function parameters {'uri'}\n```\n\n### 3. Path Parameter Approach\n```python\n@mcp.resource(\"resource://content/{path}\")\ndef get_content(path: str) -\u003e dict[str, Any]:\n # Works for simple paths but fails with slashes in {path}\n```\n\n### 4. Base Path with Query Parameters\n```python\n@mcp.resource(\"resource://content\")\ndef get_content(path: str = None) -\u003e dict[str, Any]:\n # Error: Mismatch between URI parameters set() and function parameters {'path'}\n```\n\n**Expected behavior**\n\nResource Templates with slashes in the value should be passed to the decorated function. \n\n","author":{"url":"https://github.com/phernandez","@type":"Person","name":"phernandez"},"datePublished":"2025-01-20T17:15:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/159/python-sdk/issues/159"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2a3c6b7a-a33f-84b2-5c0b-602ed9948f8f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EE34:322BC:309373:43BBDA:6A5864AA |
| html-safe-nonce | 608e2e709187929ea41105d1151260788e0b9a6e966a4166cd2fa4d970ae9540 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRTM0OjMyMkJDOjMwOTM3Mzo0M0JCREE6NkE1ODY0QUEiLCJ2aXNpdG9yX2lkIjoiNjgwNDM4MTA5NjcxOTQ0MzExNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2f45e1679d81db48cfd70393f6b6b4093cb0355d81f325d4a0c2a62649846193 |
| hovercard-subject-tag | issue:2799955044 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/159/issue_layout |
| twitter:image | https://opengraph.githubassets.com/47cf8e86c2725f6670cd0e49f713c3f193b148fcef94009a060b57580c1a4034/modelcontextprotocol/python-sdk/issues/159 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/47cf8e86c2725f6670cd0e49f713c3f193b148fcef94009a060b57580c1a4034/modelcontextprotocol/python-sdk/issues/159 |
| og:image:alt | Describe the bug Overview Resource template values containing path separators (slashes) do not work. Working Examples Simple Static Resources @mcp.resource("resource://my-resource") def get_data() ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | phernandez |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width