Skip to content

Commit a0bb3e4

Browse files
authored
fix: DeepWiki SSE is being deprecated. (#26)
* fix: Deepwiki SSE is being deprecated. * chore: 更新版本号 * chore: prettier fix
1 parent 62f7efc commit a0bb3e4

3 files changed

Lines changed: 33 additions & 7 deletions

File tree

__tests__/utils/deepwiki.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { queryDeepWiki } from '../../src/utils/deepwiki';
3+
4+
describe('DeepWiki Integration Test', () => {
5+
it('should get real response from DeepWiki for G2 question', async () => {
6+
// Set timeout to 120s as this is a real network request
7+
8+
try {
9+
const result = await queryDeepWiki({
10+
repoName: 'antvis/G2',
11+
question: '如何调整折线图两端的间隔',
12+
});
13+
14+
console.log('DeepWiki Answer:', result);
15+
16+
expect(result).toBeDefined();
17+
expect(typeof result).toBe('string');
18+
expect(result.length).toBeGreaterThan(10);
19+
// Basic check to see if it returned something relevant or at least not an error string
20+
expect(result).not.toMatch(/^Error/);
21+
} catch (error) {
22+
console.error('DeepWiki Query Failed:', error);
23+
throw error;
24+
}
25+
}, 120000);
26+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/mcp-server-antv",
3-
"version": "0.1.6",
3+
"version": "0.1.7",
44
"description": "MCP Server for AntV visualization libraries development, which provides documentation context and examples for visualization developers.",
55
"main": "build/index.js",
66
"scripts": {

src/utils/deepwiki.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
2-
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
2+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
33
import EventSource from 'eventsource';
44
import { logger } from './logger';
55
import { AntVLibrary } from '../types';
@@ -18,7 +18,7 @@ if (!global.EventSource) {
1818
// 2. 单例状态管理
1919
// ---------------------------------------------------------
2020
let _client: Client | null = null;
21-
let _transport: SSEClientTransport | null = null;
21+
let _transport: StreamableHTTPClientTransport | null = null;
2222
let _connectingPromise: Promise<Client> | null = null;
2323

2424
/**
@@ -27,7 +27,7 @@ let _connectingPromise: Promise<Client> | null = null;
2727
*/
2828
async function getMcpClient(): Promise<Client> {
2929
// 如果客户端已存在且传输层看似正常,直接返回
30-
// 注意:SSEClientTransport 目前没有直观的 isConnected 属性,
30+
// 注意:StreamableHTTPClientTransport 目前没有直观的 isConnected 属性,
3131
// 这里的检查主要是防止对象为空。更严谨的做法是监听 transport 的 close 事件来重置 _client。
3232
if (_client && _transport) {
3333
return _client;
@@ -43,8 +43,8 @@ async function getMcpClient(): Promise<Client> {
4343
try {
4444
logger.info('DeepWiki MCP: 初始化连接...');
4545

46-
const transport = new SSEClientTransport(
47-
new URL('https://mcp.deepwiki.com/sse'),
46+
const transport = new StreamableHTTPClientTransport(
47+
new URL('https://mcp.deepwiki.com/mcp'),
4848
);
4949

5050
const client = new Client(
@@ -185,7 +185,7 @@ export async function closeDeepWikiConnection() {
185185
if (_transport) {
186186
logger.info('DeepWiki MCP: 关闭连接...');
187187
// SDK 目前可能没有直接暴露 close 方法,通常关闭 transport 即可
188-
// SSEClientTransport 内部并没有显式的 close 方法暴露出来,
188+
// StreamableHTTPClientTransport 内部并没有显式的 close 方法暴露出来,
189189
// 但我们可以将引用置空,让 GC 回收,或者依赖进程退出
190190
// 如果 SSEClientTransport 实现了 close,则调用:
191191
// await _transport.close();

0 commit comments

Comments
 (0)