feat(server): accept Standard Schemas in inputRequired.elicit (#2369)
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
This commit is contained in:
parent
cc70c5e6a9
commit
24be4040d4
1 changed files with 236 additions and 17 deletions
|
|
@ -36,6 +36,10 @@ const server = new McpServer({ name: 'releases', version: '1.0.0' }, { requestSt
|
|||
|
||||
// "Return `input_required` instead of pushing a request"
|
||||
//#region registerTool_inputRequired
|
||||
const confirmationSchema = z.object({
|
||||
confirm: z.boolean().meta({ title: 'Confirm deployment' })
|
||||
});
|
||||
|
||||
server.registerTool(
|
||||
'deploy',
|
||||
{
|
||||
|
|
@ -43,13 +47,13 @@ server.registerTool(
|
|||
inputSchema: z.object({ env: z.string() })
|
||||
},
|
||||
async ({ env }, ctx): Promise<CallToolResult | InputRequiredResult> => {
|
||||
const confirmed = acceptedContent<{ confirm: boolean }>(ctx.mcpReq.inputResponses, 'confirm');
|
||||
const confirmed = acceptedContent(ctx.mcpReq.inputResponses, 'confirm', confirmationSchema);
|
||||
if (confirmed?.confirm !== true) {
|
||||
return inputRequired({
|
||||
inputRequests: {
|
||||
confirm: inputRequired.elicit({
|
||||
message: `Deploy to ${env}?`,
|
||||
requestedSchema: { type: 'object', properties: { confirm: { type: 'boolean' } }, required: ['confirm'] }
|
||||
requestedSchema: confirmationSchema
|
||||
})
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue