fix: Resource template query parameters not appended to request URI #450
This commit is contained in:
parent
7df0ac40c5
commit
2f50a4ba0e
1 changed files with 7 additions and 5 deletions
|
|
@ -16,6 +16,7 @@ import ListPane from "./ListPane";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useCompletionState } from "@/lib/hooks/useCompletionState";
|
import { useCompletionState } from "@/lib/hooks/useCompletionState";
|
||||||
import JsonView from "./JsonView";
|
import JsonView from "./JsonView";
|
||||||
|
import { UriTemplate } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
|
||||||
|
|
||||||
const ResourcesTab = ({
|
const ResourcesTab = ({
|
||||||
resources,
|
resources,
|
||||||
|
|
@ -79,10 +80,10 @@ const ResourcesTab = ({
|
||||||
template: string,
|
template: string,
|
||||||
values: Record<string, string>,
|
values: Record<string, string>,
|
||||||
): string => {
|
): string => {
|
||||||
return template.replace(
|
console.log("Expanding template:", template, "with values:", values);
|
||||||
/{([^}]+)}/g,
|
const result = new UriTemplate(template).expand(values);
|
||||||
(_, key) => values[key] || `{${key}}`,
|
console.log("Filled template:", result);
|
||||||
);
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTemplateValueChange = async (key: string, value: string) => {
|
const handleTemplateValueChange = async (key: string, value: string) => {
|
||||||
|
|
@ -240,7 +241,8 @@ const ResourcesTab = ({
|
||||||
{selectedTemplate.uriTemplate
|
{selectedTemplate.uriTemplate
|
||||||
.match(/{([^}]+)}/g)
|
.match(/{([^}]+)}/g)
|
||||||
?.map((param) => {
|
?.map((param) => {
|
||||||
const key = param.slice(1, -1);
|
// Remove leading operator characters (?, &, /, #, ;, +, .) from variable name
|
||||||
|
const key = param.slice(1, -1).replace(/^[?&/#;+.]/, "");
|
||||||
return (
|
return (
|
||||||
<div key={key}>
|
<div key={key}>
|
||||||
<Label htmlFor={key}>{key}</Label>
|
<Label htmlFor={key}>{key}</Label>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue