Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { Client } from '@modelcontextprotocol/sdk/client/index.js'; |
| 2 | import { ElicitRequestSchema } from '@modelcontextprotocol/sdk/types.js'; |
| 3 | import { type AskUser } from './approval'; |
| 4 | |
| 5 | export function createApprovalClient(askUser?: AskUser) { |
| 6 | const client = new Client( |
| 7 | { name: 'composio-approvals-example', version: '1.0.0' }, |
| 8 | { capabilities: askUser ? { elicitation: { form: {} } } : {} } |
| 9 | ); |
| 10 | if (askUser) { |
| 11 | client.setRequestHandler(ElicitRequestSchema, async request => { |
| 12 | if (request.params.mode === 'url') |
| 13 | throw new Error('This example supports form elicitation only'); |
| 14 | return askUser({ |
| 15 | type: 'elicitation', |
| 16 | mode: 'form', |
| 17 | message: request.params.message, |
| 18 | requestedSchema: request.params.requestedSchema, |
| 19 | }); |
| 20 | }); |
| 21 | } |
| 22 | return client; |
| 23 | } |