@@ -16,6 +16,7 @@ import ListPane from "./ListPane";
1616import { useEffect , useState } from "react" ;
1717import { useCompletionState } from "@/lib/hooks/useCompletionState" ;
1818import JsonView from "./JsonView" ;
19+ import { UriTemplate } from "@modelcontextprotocol/sdk/shared/uriTemplate.js" ;
1920
2021const ResourcesTab = ( {
2122 resources,
@@ -79,10 +80,10 @@ const ResourcesTab = ({
7980 template : string ,
8081 values : Record < string , string > ,
8182 ) : string => {
82- return template . replace (
83- / { ( [ ^ } ] + ) } / g ,
84- ( _ , key ) => values [ key ] || `{ ${ key } }` ,
85- ) ;
83+ console . log ( "Expanding template:" , template , "with values:" , values ) ;
84+ const result = new UriTemplate ( template ) . expand ( values ) ;
85+ console . log ( "Filled template:" , result ) ;
86+ return result ;
8687 } ;
8788
8889 const handleTemplateValueChange = async ( key : string , value : string ) => {
@@ -240,7 +241,8 @@ const ResourcesTab = ({
240241 { selectedTemplate . uriTemplate
241242 . match ( / { ( [ ^ } ] + ) } / g)
242243 ?. map ( ( param ) => {
243- const key = param . slice ( 1 , - 1 ) ;
244+ // Remove leading operator characters (?, &, /, #, ;, +, .) from variable name
245+ const key = param . slice ( 1 , - 1 ) . replace ( / ^ [ ? & / # ; + . ] / , "" ) ;
244246 return (
245247 < div key = { key } >
246248 < Label htmlFor = { key } > { key } </ Label >
0 commit comments