(version: string)
| 50 | } |
| 51 | |
| 52 | export function createWeixinMcpServer(version: string): Server { |
| 53 | const server = new Server( |
| 54 | { name: 'weixin', version }, |
| 55 | { |
| 56 | capabilities: { |
| 57 | experimental: { |
| 58 | 'claude/channel': {}, |
| 59 | 'claude/channel/permission': {}, |
| 60 | }, |
| 61 | tools: {}, |
| 62 | }, |
| 63 | instructions: |
| 64 | 'Messages from WeChat arrive as <channel source="plugin:weixin:weixin" chat_id="..." sender_id="...">. Reply using the reply tool with the chat_id from the channel tag. Use absolute paths for file attachments.', |
| 65 | }, |
| 66 | ) |
| 67 | |
| 68 | server.setRequestHandler(ListToolsRequestSchema, async () => ({ |
| 69 | tools: [ |
| 70 | { |
| 71 | name: 'reply', |
| 72 | description: |
| 73 | 'Reply to a WeChat message. Pass the chat_id from the channel tag.', |
| 74 | inputSchema: { |
| 75 | type: 'object' as const, |
| 76 | properties: { |
| 77 | chat_id: { |
| 78 | type: 'string', |
| 79 | description: 'The chat_id from the channel notification', |
| 80 | }, |
| 81 | text: { type: 'string', description: 'The reply text' }, |
| 82 | files: { |
| 83 | type: 'array', |
| 84 | items: { type: 'string' }, |
| 85 | description: 'Optional absolute file paths to attach', |
| 86 | }, |
| 87 | }, |
| 88 | required: ['chat_id', 'text'], |
| 89 | }, |
| 90 | }, |
| 91 | { |
| 92 | name: 'send_typing', |
| 93 | description: 'Send a typing indicator to a WeChat user.', |
| 94 | inputSchema: { |
| 95 | type: 'object' as const, |
| 96 | properties: { |
| 97 | chat_id: { type: 'string', description: 'The chat_id (user ID)' }, |
| 98 | }, |
| 99 | required: ['chat_id'], |
| 100 | }, |
| 101 | }, |
| 102 | ], |
| 103 | })) |
| 104 | |
| 105 | server.setRequestHandler(CallToolRequestSchema, async request => { |
| 106 | const { name, arguments: args } = request.params |
| 107 | const account = loadAccount() |
| 108 | if (!account) { |
| 109 | return { |
no test coverage detected