Skip to content

MCP System Core

Model Context Protocol implementation for AI tool calling.

Overview

MCP (Model Context Protocol) is an open standard by Anthropic for AI-tool interactions.

Core Components

ComponentFileResponsibility
McpManagersrc/mcp/McpManager.jsTool registration and routing
McpClientsrc/mcp/McpClient.jsMCP protocol client
BuiltinMcpServersrc/mcp/BuiltinMcpServer.jsBuilt-in tool management

McpManager

Central hub for all tool sources:

javascript
class McpManager {
  // Register tool source
  registerToolSource(source) { }
  
  // List all available tools
  async listTools() { }
  
  // Call a tool
  async callTool(name, args, context) { }
}

McpClient

Supports multiple transport protocols:

TransportDescriptionUse Case
stdioProcess stdin/stdoutLocal CLI tools
npmnpm package with npxnpm MCP servers
SSEServer-Sent EventsRemote servers
HTTPHTTP requestsREST APIs

BuiltinMcpServer

Manages built-in tools with features:

  • Hot Reload - Update tools without restart
  • Category Management - Enable/disable by category
  • Context Injection - Provide runtime context to tools

Tool Context

ToolContext provides runtime info to tools:

javascript
const ctx = getBuiltinToolContext()

ctx.getBot()        // Bot instance
ctx.getEvent()      // Message event
ctx.isMaster        // Is master user
ctx.getAdapter()    // Adapter info

Configuration

json
// data/mcp-servers.json
{
  "servers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@anthropic/mcp-server-filesystem"]
    }
  }
}

Next Steps

Released under the MIT License