mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Bryanmorgan/add mcp description support (#825)
This commit is contained in:
@@ -49,6 +49,8 @@ export class MCPServerConfig {
|
||||
// Common
|
||||
readonly timeout?: number,
|
||||
readonly trust?: boolean,
|
||||
// Metadata
|
||||
readonly description?: string,
|
||||
) {}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('DiscoveredMCPTool', () => {
|
||||
});
|
||||
|
||||
describe('constructor', () => {
|
||||
it('should set properties correctly and augment description (non-generic server)', () => {
|
||||
it('should set properties correctly (non-generic server)', () => {
|
||||
const tool = new DiscoveredMCPTool(
|
||||
mockCallableToolInstance,
|
||||
serverName, // serverName is 'mock-mcp-server', not 'mcp'
|
||||
@@ -64,14 +64,13 @@ describe('DiscoveredMCPTool', () => {
|
||||
|
||||
expect(tool.name).toBe(toolNameForModel);
|
||||
expect(tool.schema.name).toBe(toolNameForModel);
|
||||
const expectedDescription = `${baseDescription}\n\nThis MCP tool named '${serverToolName}' was discovered from an MCP server.`;
|
||||
expect(tool.schema.description).toBe(expectedDescription);
|
||||
expect(tool.schema.description).toBe(baseDescription);
|
||||
expect(tool.schema.parameters).toEqual(inputSchema);
|
||||
expect(tool.serverToolName).toBe(serverToolName);
|
||||
expect(tool.timeout).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should set properties correctly and augment description (generic "mcp" server)', () => {
|
||||
it('should set properties correctly (generic "mcp" server)', () => {
|
||||
const genericServerName = 'mcp';
|
||||
const tool = new DiscoveredMCPTool(
|
||||
mockCallableToolInstance,
|
||||
@@ -81,8 +80,7 @@ describe('DiscoveredMCPTool', () => {
|
||||
inputSchema,
|
||||
serverToolName,
|
||||
);
|
||||
const expectedDescription = `${baseDescription}\n\nThis MCP tool named '${serverToolName}' was discovered from '${genericServerName}' MCP server.`;
|
||||
expect(tool.schema.description).toBe(expectedDescription);
|
||||
expect(tool.schema.description).toBe(baseDescription);
|
||||
});
|
||||
|
||||
it('should accept and store a custom timeout', () => {
|
||||
|
||||
@@ -30,17 +30,6 @@ export class DiscoveredMCPTool extends BaseTool<ToolParams, ToolResult> {
|
||||
readonly timeout?: number,
|
||||
readonly trust?: boolean,
|
||||
) {
|
||||
if (serverName !== 'mcp') {
|
||||
// Add server name if not the generic 'mcp'
|
||||
description += `
|
||||
|
||||
This MCP tool named '${serverToolName}' was discovered from an MCP server.`;
|
||||
} else {
|
||||
description += `
|
||||
|
||||
This MCP tool named '${serverToolName}' was discovered from '${serverName}' MCP server.`;
|
||||
}
|
||||
|
||||
super(
|
||||
name,
|
||||
name,
|
||||
|
||||
Reference in New Issue
Block a user