MCP API
The MCP (Model Context Protocol) API provides comprehensive access to MCP servers and tools, enabling you to discover, configure, and execute tools across multiple servers.
Overview
The MCP module enables you to:
- Discover Servers: Find available and enabled MCP servers
- Manage Tools: List, configure, and execute tools
- Search: Search for servers and tools by query
- Configure: Set up servers and tools with custom configurations
Quick Start Example
// Get enabled MCP servers
const enabledServers = await codebolt.mcp.getEnabledMCPServers();
console.log('Enabled servers:', enabledServers);
// Get all tools from enabled servers
const allTools = await codebolt.mcp.getAllMcpTools();
console.log('Available tools:', allTools);
// Execute a tool
const result = await codebolt.mcp.executeTool(
'server-name',
'tool-name',
{ param1: 'value1' }
);
console.log('Execution result:', result);
Common Use Cases
Tool Discovery
Discover and explore available tools:
async function discoverTools() {
// Get list of all MCP servers
const servers = await codebolt.mcp.getMcpList();
// Get tools from specific servers
const tools = await codebolt.mcp.getMcpTools(['server1', 'server2']);
return { servers, tools };
}
Tool Execution
Execute tools with parameters:
async function runTool(server, tool, params) {
const result = await codebolt.mcp.executeTool(server, tool, params);
return result;
}
Response Structure
MCP API functions return typed responses:
Server Discovery:
GetEnabledMCPSResponse: List of enabled serversGetMcpListResponse: List of all available serversGetLocalToolBoxesResponse: Local server information
Tool Operations:
GetAllMCPToolsResponse: All tools from enabled serversExecuteToolResponse: Tool execution resultsGetToolsResponse: Detailed tool information
- getEnabledMCPServers - Gets the list of currently enabled MCP servers.
- getLocalMCPServers - Gets the list of locally available MCP servers.
- getMentionedMCPServers - Gets MCP servers mentioned in a user message.
- searchAvailableMCPServers - Searches for available MCP servers matching a query.
- listMcpFromServers - Lists all tools from specified MCP servers.
- configureMCPServer - Configures a specific MCP server with provided configuration.
- getTools - Gets detailed information about specific tools.
- executeTool - Executes a specific tool with provided parameters.
- getMcpTools - Gets MCP tools from specified servers.
- getMcpList - Gets the list of available MCP servers.
- getAllMcpTools - Gets all tools from all enabled MCP servers.
- getEnabledMcps - Gets the list of enabled MCP servers.
- configureMcpTool - Configures a specific MCP tool with provided configuration.