Merge branch 'main' into elicitation-support
This commit is contained in:
commit
5ab3a00f5c
1 changed files with 44 additions and 0 deletions
|
|
@ -92,6 +92,14 @@ const ElicitationSchema = z.object({
|
||||||
.boolean()
|
.boolean()
|
||||||
.default(true)
|
.default(true)
|
||||||
.describe("Whether to include the favorite things schema"),
|
.describe("Whether to include the favorite things schema"),
|
||||||
|
|
||||||
|
const GetResourceLinksSchema = z.object({
|
||||||
|
count: z
|
||||||
|
.number()
|
||||||
|
.min(1)
|
||||||
|
.max(10)
|
||||||
|
.default(3)
|
||||||
|
.describe("Number of resource links to return (1-10)"),
|
||||||
});
|
});
|
||||||
|
|
||||||
enum ToolName {
|
enum ToolName {
|
||||||
|
|
@ -104,6 +112,7 @@ enum ToolName {
|
||||||
ANNOTATED_MESSAGE = "annotatedMessage",
|
ANNOTATED_MESSAGE = "annotatedMessage",
|
||||||
GET_RESOURCE_REFERENCE = "getResourceReference",
|
GET_RESOURCE_REFERENCE = "getResourceReference",
|
||||||
ELICITATION = "startElicitation",
|
ELICITATION = "startElicitation",
|
||||||
|
GET_RESOURCE_LINKS = "getResourceLinks",
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PromptName {
|
enum PromptName {
|
||||||
|
|
@ -489,6 +498,12 @@ export const createServer = () => {
|
||||||
description: "Demonstrates the Elicitation feature by asking the user to provide information about their favorite color, number, and pets.",
|
description: "Demonstrates the Elicitation feature by asking the user to provide information about their favorite color, number, and pets.",
|
||||||
inputSchema: zodToJsonSchema(ElicitationSchema) as ToolInput,
|
inputSchema: zodToJsonSchema(ElicitationSchema) as ToolInput,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: ToolName.GET_RESOURCE_LINKS,
|
||||||
|
description:
|
||||||
|
"Returns multiple resource links that reference different types of resources",
|
||||||
|
inputSchema: zodToJsonSchema(GetResourceLinksSchema) as ToolInput,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return { tools };
|
return { tools };
|
||||||
|
|
@ -709,6 +724,35 @@ export const createServer = () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (name === ToolName.GET_RESOURCE_LINKS) {
|
||||||
|
const { count } = GetResourceLinksSchema.parse(args);
|
||||||
|
const content = [];
|
||||||
|
|
||||||
|
// Add intro text
|
||||||
|
content.push({
|
||||||
|
type: "text",
|
||||||
|
text: `Here are ${count} resource links to resources available in this server (see full output in tool response if your client does not support resource_link yet):`,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Return resource links to actual resources from ALL_RESOURCES
|
||||||
|
const actualCount = Math.min(count, ALL_RESOURCES.length);
|
||||||
|
for (let i = 0; i < actualCount; i++) {
|
||||||
|
const resource = ALL_RESOURCES[i];
|
||||||
|
content.push({
|
||||||
|
type: "resource_link",
|
||||||
|
uri: resource.uri,
|
||||||
|
name: resource.name,
|
||||||
|
description: `Resource ${i + 1}: ${
|
||||||
|
resource.mimeType === "text/plain"
|
||||||
|
? "plaintext resource"
|
||||||
|
: "binary blob resource"
|
||||||
|
}`,
|
||||||
|
mimeType: resource.mimeType,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return { content };
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`Unknown tool: ${name}`);
|
throw new Error(`Unknown tool: ${name}`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue