MCP Plugin Framework
Relevant source files
The following files were used as context for generating this wiki page:
The Model Context Protocol (MCP) Plugin Framework enables the Agent application to connect Large Language Models (LLMs) to local and remote machine context. It provides a standardized interface for discovery, registration, and invocation of system tools and sandbox skills. The framework allows models to interact with the local filesystem, perform web searches, and manage semantic memory through structured tool calls.
The system distinguishes between MCP System Tools, which are external services providing functional capabilities, and Skill Plugins, which are internal sandbox modules that render specific data types like SVG or LaTeX.
Sources: src/components/PluginMCP.tsx:1-25, src/data.ts:98-200
Architecture and Discovery
The framework operates by maintaining a registry of MCP configurations and skill plugins. Users register new MCP servers by providing a service name, an endpoint URL, and a broker description. The system performs a handshake to validate the connection and discover exposed tools.
Registry Management
The PluginMCP component manages the lifecycle of these integrations:
- Registration: Captures endpoint URLs and metadata for new MCP brokers.
- Discovery: Enumerates tools exposed by a connected server, including their JSON schemas.
- State Management: Controls the
isEnabledandstatus(connected/offline) flags for each plugin.
Tool Invocation Flow
When a user submits a prompt, the system analyzes the input for semantic triggers. If a prompt requires external context, the AI utility intercepts the request and dispatches a tool call to the relevant MCP server.
Execution Sequence
- The
generateChatResponsefunction identifies matching tools based on the prompt content. - The system checks if the target MCP is enabled and connected.
- A JSON-RPC style payload is constructed, containing the tool name and arguments.
- The MCP broker executes the action (e.g., reading a file) and returns an output buffer.
- The assistant incorporates the tool output into the chat history.
Sources: src/utils/ai.ts:80-130, src/data.ts:225-245
Core MCP Modules
The framework includes several default MCP configurations that provide fundamental capabilities to the Agent.
| MCP Service | Default URL | Core Tools | Description |
|---|---|---|---|
| Local Filesystem | http://localhost:3011 | read_file, write_file, ls | Provides deep read/write access to the local workspace. |
| Web Browser | http://localhost:3012 | query_web_search, scrape_doc | Accesses Brave/Google search indexes and web scraping. |
| Semantic Memory | http://localhost:3013 | memorize_fact, query_memory | Embeds facts and preferences into a vector store. |
Sources: src/data.ts:107-178
Sandbox Skill Plugins
Skill Plugins are client-side renderers that intercept specific output formats from the LLM. These are managed alongside MCPs but operate within the ChatArea sandbox.
Skill Categories
- Graphics: The Visual SVG Sandbox renders XML vector code blocks into an interactive canvas.
- Math: The LaTeX Typesetter formats mathematical formulas using crisp typography.
- Utility: The JS / Code Playground executes lightweight scripts in a secure iframe.
Implementation Details
Autocomplete Integration
The ChatArea uses a specific syntax to trigger MCP and Plugin interactions manually:
/triggers Prompt Presets for behavior overlays.@triggers File Attachment from the virtual filesystem.#triggers MCP Tool suggestions from enabled servers.
Sources: src/components/ChatArea.tsx:110-160
Tool Call Schema
MCP tools are defined using JSON Schema to ensure the LLM provides valid arguments.
{
"name": "write_filesystem_file",
"description": "Create or overwrite files with textual payloads.",
"inputSchema": {
"type": "object",
"properties": {
"path": { "type": "string" },
"content": { "type": "string" }
},
"required": ["path", "content"]
}
}
Sources: src/data.ts:123-135
The MCP Plugin Framework serves as the primary bridge between the stateless LLM and the stateful local environment, ensuring all interactions are governed by user-enabled permissions and explicit tool schemas.
Sources: src/screens/MainScreen.tsx:105-130, src/utils/ai.ts:200-215