Efficient TypeScript SDK and CLI for managing reusable MCP servers with lifecycle control and error handling
mcp-runner
MCP Server?mcp-runner
is a specialized TypeScript SDK and command-line interface (CLI) designed to facilitate the execution of Model Context Protocol (MCP) servers based on configurations defined in cline_mcp_settings.json
. This server enables seamless integration between AI applications, data sources, and tools through the MCP protocol. By leveraging reusable server processes and controlled cleanup mechanisms, it supports efficient execution of multiple operations using a single server instance.
mcp-runner
optimizes resource usage by reusing the same server process across multiple calls to run different tools on the same server. This feature reduces startup overhead and enhances overall performance, making it an ideal choice for applications that require frequent interactions with a single server.
The SDK handles graceful termination of servers when requests are no longer needed. It includes robust timeout mechanisms to ensure that servers respond within predefined time limits, preventing unnecessary hangs or delays.
mcp-runner
ensures the automatic management of server processes through its lifecycle, starting and stopping them as required. This dynamic approach is crucial for maintaining a balanced system load and ensuring consistent performance.
Comprehensive error handling and logging capabilities are built into mcp-runner
, making it easier to diagnose issues and maintain robust applications. The SDK supports TypeScript, allowing developers to take full advantage of this modern JavaScript language.
mcp-runner
is architected as a single point of entry for AI applications, leveraging the Model Context Protocol (MCP) to standardize interactions with data sources and tools. The architecture involves:
mcp-runner
using a standardized protocol.mcp-runner
manages server processes and tool execution, ensuring that requests are efficiently processed and responses are timely.The following Mermaid diagram illustrates the flow of interactions between an AI application (MCP client) and the mcp-runner
MCP server:
graph TD
A[AI Application] -->|MCP Client| B[MCP Protocol]
B --> C[MCP Server]
C --> D[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
style D fill:#e8f5e8
The following diagram details the data architecture within mcp-runner
:
graph TD
A[Server Manager] --> B[Tool Execution]
C[Configured Servers] -->|Initialization| A
D[Event Loop] --> E[Logger]
F[Error Handling Mechanisms] --> G[Process Management]
style C fill:#e8f5e8
style A fill:#f3e5f5
style B fill:#e1f5fe
To get started, first ensure you have Node.js and npm installed. Then install mcp-runner
using the following command:
npm install
Once installed, you can use either the CLI or integrate it into your TypeScript projects.
For CLI usage, refer to the commands provided in the README. Here’s a brief overview:
list-tools <server-name>
: Lists available tools for a specified server.runserver <server-name> [tool-name] [params] [options]
: Runs a tool on the specified server with optional parameters.Imagine an application where users can ask complex questions about their medical history to a digital assistant. The mcp-runner
integrates seamlessly with healthcare tools and data sources, using MCP to pass relevant prompts and receive structured responses.
import { runServer } from 'mcp-runner';
async function main() {
try {
const response = await runServer('medical-helper', 'get-medical-history', {
user_id: 12345,
date_range: ['2023-01-01', '2023-12-31']
});
console.log(response);
} catch (error) {
console.error(error);
}
}
In another application, writers can use mcp-runner
to generate content by prompting a natural language processing tool. The MCP server processes the text request and delivers the generated text back to the user.
As mentioned earlier, mcp-runner
is compatible with popular MCP clients such as:
MCP Client | Resources | Tools | Prompts | Status |
---|---|---|---|---|
Claude Desktop | ✅ | ✅ | ✅ | Full Support |
Continue | ✅ | ✅ | 🟡 | Partial Support |
Cursor | ❌ | ✅ | ✍️ | Tools Only |
{
"mcpServers": {
"medical-helper": {
"command": "node",
"args": ["-r", "esm", "server.js"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
Ensure that all configurations are secure, and sensitive information like API keys are stored securely.
mcp-runner
with an AI application?Integrate by configuring the cline_mcp_settings.json
file to match your server setup and using the provided CLI or library methods in TypeScript projects.
mcp-runner
with multiple MCP clients simultaneously?Yes, you can run different servers concurrently within the same process for maximum resource efficiency.
The SDK handles server process errors, tool execution failures, timeout issues, and ensures automatic cleanup on errors.
Yes, you can extend or modify CLI commands as needed to support additional features or compatibility requirements.
mcp-runner
?Refer to the error logs and consider the MCP protocol flow diagram for troubleshooting steps. Detailed documentation on common issues and debugging techniques is available in the GitHub repository.
Contributions are welcome! Please ensure all pull requests include detailed descriptions, tests, and adhere to existing coding standards.
npm run build
npm test
For more information about the Model Context Protocol and its ecosystem, visit ModelContextProtocol.org.
This comprehensive documentation positions mcp-runner
as a robust solution for integrating AI applications with data sources and tools through the Model Context Protocol.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica