Merge branch 'main' into bugfix/authorization-url-generate-state

This commit is contained in:
Ola Hungerford 2025-07-26 20:41:35 -07:00 • committed by GitHub
commit 94c75204fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 301 additions and 88 deletions

View file

@ -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,
@ -66,6 +67,7 @@ export function useCompletionState(
ref: ResourceReference | PromptReference,
argName: string,
value: string,
context?: Record<string, string>,
) => {
if (!completionsSupported) {
return;
@ -82,10 +84,15 @@ export function useCompletionState(
}));
try {
if (context !== undefined) {
delete context[argName];
}
const values = await handleCompletion(
ref,
argName,
value,
context,
abortController.signal,
);
@ -97,6 +104,7 @@ export function useCompletionState(
}));
}
} catch {
console.error("completion failed");
if (!abortController.signal.aborted) {
setState((prev) => ({
...prev,

View file

@ -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) {
@ -215,6 +216,12 @@ export function useConnection({
},
};
if (context) {
request["params"]["context"] = {
arguments: context,
};
}
try {
const response = await makeRequest(request, CompleteResultSchema, {
signal,