modelcontextprotocol / modelcontextprotocol/typescript-sdk
Resource Templates: Support for display names vs values in completion and better handling of special characters in URI paths
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13.4k
- Forks
- 2.2k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 4
Description
Problem
When using ResourceTemplates with URI parameters that contain special characters (like forward slashes), there are two main UX issues:
- Ugly encoded values in completion UI: Users see URL-encoded strings like
kubernetes%2Fapps-use2-prdinstead of readable names likekubernetes/apps-use2-prd - URI path conflicts: Even with proper encoding, URIs with special characters in template parameters can cause path resolution issues
Current Workaround
Currently, developers have to choose between:
- Using URL encoding (ugly UX, potential resolution issues)
- Using custom separators like
--(readable but non-standard naming)
Proposed Solution
1. Support Display Names vs Values in Completion
Allow completion functions to return objects with separate display and value properties:
complete: {
authPath: async (_arg: string): Promise<Array<string | {display: string, value: string}>> => {
return [
{ display: "kubernetes/apps-use2-prd", value: "kubernetes%2Fapps-use2-prd" },
{ display: "github-oidc", value: "github-oidc" }, // or just strings for simple cases
"aws" // backward compatibility
];
}
}
2. Automatic URI Encoding/Decoding
The SDK should automatically:
- URL-encode template parameters when constructing URIs
- URL-decode template parameters when passing to readCallback
- Handle this transparently so developers don't need to manage encoding
Use Case
We're building Vault auth method resources where paths like kubernetes/usw2-dev contain forward slashes that conflict with URI path structure. This pattern is common in many systems (file paths, namespace hierarchies, etc.).
Example
// What users see in completion
"kubernetes/apps-use2-prd"
// What gets encoded in URI
"vault://auth/kubernetes%2Fapps-use2-prd"
// What readCallback receives (decoded)
variables.authPath === "kubernetes/apps-use2-prd"
This would provide a much better developer and end-user experience for ResourceTemplates with hierarchical or special-character naming schemes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the ResourceTemplates completion functions, URI construction, and readCallback entry points described in the issue. Determine how display/value pairs and encoded parameters should flow through these paths, then verify that completion shows readable names, URIs encode special characters, and readCallback receives decoded values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100