Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/src/components/PromptsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const PromptsTab = ({
ref: PromptReference | ResourceReference,
argName: string,
value: string,
context?: Record<string, string>,
) => Promise<string[]>;
completionsSupported: boolean;
promptContent: string;
Expand All @@ -73,6 +74,7 @@ const PromptsTab = ({
},
argName,
value,
promptArgs,
);
}
};
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/ResourcesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const ResourcesTab = ({
ref: ResourceReference | PromptReference,
argName: string,
value: string,
context?: Record<string, string>,
) => Promise<string[]>;
completionsSupported: boolean;
resourceContent: string;
Expand Down Expand Up @@ -94,6 +95,7 @@ const ResourcesTab = ({
},
key,
value,
templateValues,
);
}
};
Expand Down
8 changes: 8 additions & 0 deletions client/src/lib/hooks/useCompletionState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function useCompletionState(
ref: ResourceReference | PromptReference,
argName: string,
value: string,
context?: Record<string, string>,
signal?: AbortSignal,
) => Promise<string[]>,
completionsSupported: boolean = true,
Expand Down Expand Up @@ -66,6 +67,7 @@ export function useCompletionState(
ref: ResourceReference | PromptReference,
argName: string,
value: string,
context?: Record<string, string>,
) => {
if (!completionsSupported) {
return;
Expand All @@ -82,10 +84,15 @@ export function useCompletionState(
}));

try {
if (context !== undefined) {
delete context[argName];
}

const values = await handleCompletion(
ref,
argName,
value,
context,
abortController.signal,
);

Expand All @@ -97,6 +104,7 @@ export function useCompletionState(
}));
}
} catch {
console.error("completion failed");
if (!abortController.signal.aborted) {
setState((prev) => ({
...prev,
Expand Down
7 changes: 7 additions & 0 deletions client/src/lib/hooks/useConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export function useConnection({
ref: ResourceReference | PromptReference,
argName: string,
value: string,
context?: Record<string, string>,
signal?: AbortSignal,
): Promise<string[]> => {
if (!mcpClient || !completionsSupported) {
Expand All @@ -215,6 +216,12 @@ export function useConnection({
},
};

if (context) {
request["params"]["context"] = {
arguments: context,
};
}

try {
const response = await makeRequest(request, CompleteResultSchema, {
signal,
Expand Down