How mcspidey/mcpi works
Main Components
• MCPI Server: This is the core backend written in Rust (located in the “mcpi-server” folder). It includes:
• A plugin registry and plugin engine (with built-in plugins for “hello”, “social”, “store”, “weather”, “website”).
• Communication modules for handling WebSocket connections (MCPI protocol endpoints) and HTTP-based REST discovery.
• Routing components (message_handler.rs and transport layers in “mcpi-server/src/transport” for protocol data transmission).
• Static files (like admin.html) and configuration files stored in the “data” folder.
• MCPI Client: This is a command-line client (in “mcpi-client”) responsible for:
• DNS-based server discovery.
• Direct WebSocket connection to the server.
• Option to test individual plugins.
• mcpi-common Library: Shared code and interfaces (located in “mcpi-common”) that defines JSON plugins, plugin factories, and common protocols.
• Chrome Extension: Found in the “chrome-extension” folder. It acts as a front-end integration tool that:
• Detects MCPI-enabled sites via DNS TXT records.
• Provides a popup interface with quick actions and tool exploration.
• Supporting Data and Configuration:
• The “data” directory contains JSON configuration files and dataset files for different domains (client, hello, server, social, store, weather, website).
• Docker configuration under “docker” for containerizing the server.
Relationships and Interactions
• The MCPI Server exposes two types of endpoints:
• A WebSocket endpoint (e.g., at ws://localhost:3001/mcpi) for MCP protocol communications.
• A REST discovery endpoint (e.g., http://localhost:3001/mcpi/discover) for capability discovery.
• The Server uses a plugin-based, modular architecture where each plugin (e.g., hello, store, weather) implements the McpPlugin trait.
• The plugin registry is responsible for routing incoming requests (including standard operations like SEARCH, GET, and LIST) to the appropriate plugin.
• The MCPI Client uses DNS-based discovery (using TXT records) and HTTP lookup to find the server before establishing a WebSocket connection.
• The Chrome Extension integrates with the MCPI server by automatically detecting a supported website, then connecting and allowing the user to interact with the available tools.
Architectural Patterns and Design Principles
• Modular Plugin Architecture: Plugins are self-contained, enabling dynamic extension without altering core server logic.
• Separation of Concerns: Clearly separated components for client, server, and shared libraries.
• Protocol Abstraction: Implementation of the Model Context Protocol through dedicated transport modules (WebSocket and HTTP REST).
• Data-Driven Configuration: The system relies on external JSON configuration files and data files, making the system flexible.
Relevant Technologies
• Rust and Cargo for building the server, client, and shared libraries.
• WebSocket and HTTP for communications.
• DNS TXT-based discovery mechanism.
• Chrome extension APIs for browser integration.
• Docker for containerized deployment of server components.