feat(wecom): 企微 API 插件增加 MCP Streamable HTTP 端点
与 REST/OpenAPI 并存,按实例权限自动 tools/list,免手填工具。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { wecomPluginCaller, wecomPluginMcpErrorText, wecomPluginQueryArg } from './wecom-plugin.util';
|
||||
|
||||
describe('wecomPluginCaller', () => {
|
||||
it('prefers X-WeCom-User-Id', () => {
|
||||
expect(wecomPluginCaller({ headers: { 'x-wecom-userid': 'alice', userid: 'bob' } })).toBe('alice');
|
||||
});
|
||||
|
||||
it('falls back to plugin', () => {
|
||||
expect(wecomPluginCaller({ headers: {} })).toBe('plugin');
|
||||
});
|
||||
});
|
||||
|
||||
describe('wecomPluginMcpErrorText', () => {
|
||||
it('unwraps Nest HttpException message', () => {
|
||||
expect(wecomPluginMcpErrorText(new BadRequestException('请提供查询关键词 q'))).toBe('请提供查询关键词 q');
|
||||
});
|
||||
});
|
||||
|
||||
describe('wecomPluginQueryArg', () => {
|
||||
it('stringifies numbers and drops empty', () => {
|
||||
expect(wecomPluginQueryArg(2)).toBe('2');
|
||||
expect(wecomPluginQueryArg(' ')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user