Context Injection
Relevant source files
The following files were used as context for generating this wiki page:
Context Injection is a core mechanism in the mcpmcp-server architecture designed to facilitate the integration of Model Context Protocol (MCP) servers with various AI clients. It allows for the discovery, setup, and seamless delivery of external tool contexts and capabilities into the AI's operational workflow.
By utilizing a remote bridging strategy, the system injects necessary server configurations and operational logic into clients like Claude Desktop. This enables the client to interact with remote MCP endpoints as if they were local services, expanding the AI's functional reach through a standardized protocol.
Sources: README.md:1-5, package.json:1-10
Architecture and Integration
The injection process is initiated via the client's configuration file. The mcpmcp-server acts as a middleman (proxy) that translates remote MCP resources into a format the local client can consume.
Connection Workflow
The system utilizes npx to execute a remote bridge (mcp-remote) which points to the mcpmcp.io endpoint. This connection establishes the tunnel through which context and tools are injected into the client's environment.
The diagram above shows the flow of context from the remote repository through the bridge and into the local client application.
Sources: README.md:11-19
Configuration Management
Context injection is managed through a specific JSON structure within the MCP client's settings. This configuration defines the command-line arguments required to initialize the context injection bridge.
Configuration Schema
The following table describes the required fields for successful context injection within a client's mcpServers configuration:
| Field | Type | Description |
|---|---|---|
command | String | The executable command (typically npx). |
args | Array | Includes -y, the package name mcp-remote@latest, and the source URL. |
source_url | String | The remote endpoint providing the context (e.g., https://mcpmcp.io/mcp). |
Sources: README.md:14-18
Implementation Example
A standard implementation for injecting context into Claude Desktop on macOS:
{
"mcpServers": {
"mcpmcp": {
"command": "npx",
"args": ["-y", "mcp-remote@latest", "https://mcpmcp.io/mcp"]
}
}
}
Sources: README.md:13-21
Context Resolution Logic
While the client sees a local process, the mcpmcp-server resolves context dynamically. This involves fetching tool definitions and resource schemas from the remote endpoint and presenting them as standard MCP primitives to the host application.
This sequence illustrates how the bridge intercepts initialization to inject remote capabilities before the AI starts processing user queries.
Sources: src/index.ts, src/context.ts
Summary
Context Injection in mcpmcp-server simplifies the complex task of connecting disparate AI tools. By abstracting the connection logic into a single configuration entry, it allows users to unlock the full potential of remote MCP servers within their local daily workflow without manual manual dependency management or local installation of every individual tool server.
Sources: README.md:3-5