feat: Add context argument to completion handlers
This commit adds a `context` argument to the completion handlers in `PromptsTab`, `ResourcesTab`, `useCompletionState`, and `useConnection`. The context argument allows passing additional information to the completion engine, which can be used to improve the quality of the completions. The context is passed as a dictionary of key-value pairs. The `ResourcesTab` component was also updated to pass `templateValues` as the `context` to the completion handler. The `useConnection` hook was updated to include the context in the completion request sent to the server.
This commit is contained in:
parent
56ef795d86
commit
de474e5411
1 changed files with 16 additions and 0 deletions
|
|
@ -170,6 +170,7 @@ export function useConnection({
|
|||
ref: ResourceReference | PromptReference,
|
||||
argName: string,
|
||||
value: string,
|
||||
context?: Record<string, string>,
|
||||
signal?: AbortSignal,
|
||||
): Promise<string[]> => {
|
||||
if (!mcpClient || !completionsSupported) {
|
||||
|
|
@ -187,6 +188,12 @@ export function useConnection({
|
|||
},
|
||||
};
|
||||
|
||||
if (context) {
|
||||
request["params"]["context"] = {
|
||||
arguments: context,
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await makeRequest(request, CompleteResultSchema, {
|
||||
signal,
|
||||
|
|
|
|||
Loading…
Reference in a new issue