feat(core): add tools to list and read MCP resources (#25395)

This commit is contained in:
ruomeng
2026-04-16 13:57:43 -04:00
committed by GitHub
parent 963631a3d4
commit f16f1cced3
26 changed files with 1126 additions and 6 deletions
@@ -137,3 +137,7 @@ export const TOPIC_PARAM_STRATEGIC_INTENT = 'strategic_intent';
// -- complete_task --
export const COMPLETE_TASK_TOOL_NAME = 'complete_task';
export const COMPLETE_TASK_DISPLAY_NAME = 'Complete Task';
// -- MCP Resources --
export const READ_MCP_RESOURCE_TOOL_NAME = 'read_mcp_resource';
export const LIST_MCP_RESOURCES_TOOL_NAME = 'list_mcp_resources';
@@ -43,6 +43,8 @@ export {
UPDATE_TOPIC_DISPLAY_NAME,
COMPLETE_TASK_TOOL_NAME,
COMPLETE_TASK_DISPLAY_NAME,
READ_MCP_RESOURCE_TOOL_NAME,
LIST_MCP_RESOURCES_TOOL_NAME,
// Shared parameter names
PARAM_FILE_PATH,
PARAM_DIR_PATH,
@@ -280,3 +282,17 @@ export function getActivateSkillDefinition(
overrides: (modelId) => getToolSet(modelId).activate_skill(skillNames),
};
}
export const READ_MCP_RESOURCE_DEFINITION: ToolDefinition = {
get base() {
return DEFAULT_LEGACY_SET.read_mcp_resource;
},
overrides: (modelId) => getToolSet(modelId).read_mcp_resource,
};
export const LIST_MCP_RESOURCES_DEFINITION: ToolDefinition = {
get base() {
return DEFAULT_LEGACY_SET.list_mcp_resources;
},
overrides: (modelId) => getToolSet(modelId).list_mcp_resources,
};
@@ -25,6 +25,8 @@ import {
GET_INTERNAL_DOCS_TOOL_NAME,
ASK_USER_TOOL_NAME,
ENTER_PLAN_MODE_TOOL_NAME,
READ_MCP_RESOURCE_TOOL_NAME,
LIST_MCP_RESOURCES_TOOL_NAME,
// Shared parameter names
PARAM_FILE_PATH,
PARAM_DIR_PATH,
@@ -756,4 +758,37 @@ The agent did not use the todo list because this task could be completed by a ti
exit_plan_mode: () => getExitPlanModeDeclaration(),
activate_skill: (skillNames) => getActivateSkillDeclaration(skillNames),
read_mcp_resource: {
name: READ_MCP_RESOURCE_TOOL_NAME,
description:
'Reads the content of a specified Model Context Protocol (MCP) resource.',
parametersJsonSchema: {
type: 'object',
properties: {
uri: {
description: 'The URI of the MCP resource to read.',
type: 'string',
},
},
required: ['uri'],
},
},
list_mcp_resources: {
name: LIST_MCP_RESOURCES_TOOL_NAME,
description:
'Lists all available resources exposed by connected MCP servers.',
parametersJsonSchema: {
type: 'object',
properties: {
serverName: {
description:
'Optional filter to list resources from a specific server.',
type: 'string',
},
},
required: [],
},
},
};
@@ -25,6 +25,8 @@ import {
GET_INTERNAL_DOCS_TOOL_NAME,
ASK_USER_TOOL_NAME,
ENTER_PLAN_MODE_TOOL_NAME,
READ_MCP_RESOURCE_TOOL_NAME,
LIST_MCP_RESOURCES_TOOL_NAME,
// Shared parameter names
PARAM_FILE_PATH,
PARAM_DIR_PATH,
@@ -733,4 +735,37 @@ The agent did not use the todo list because this task could be completed by a ti
exit_plan_mode: () => getExitPlanModeDeclaration(),
activate_skill: (skillNames) => getActivateSkillDeclaration(skillNames),
update_topic: getUpdateTopicDeclaration(),
read_mcp_resource: {
name: READ_MCP_RESOURCE_TOOL_NAME,
description:
'Reads the content of a specified Model Context Protocol (MCP) resource.',
parametersJsonSchema: {
type: 'object',
properties: {
uri: {
description: 'The URI of the MCP resource to read.',
type: 'string',
},
},
required: ['uri'],
},
},
list_mcp_resources: {
name: LIST_MCP_RESOURCES_TOOL_NAME,
description:
'Lists all available resources exposed by connected MCP servers.',
parametersJsonSchema: {
type: 'object',
properties: {
serverName: {
description:
'Optional filter to list resources from a specific server.',
type: 'string',
},
},
required: [],
},
},
};
@@ -50,5 +50,7 @@ export interface CoreToolSet {
enter_plan_mode: FunctionDeclaration;
exit_plan_mode: () => FunctionDeclaration;
activate_skill: (skillNames: string[]) => FunctionDeclaration;
read_mcp_resource: FunctionDeclaration;
list_mcp_resources: FunctionDeclaration;
update_topic?: FunctionDeclaration;
}