mcp-in-docker

eooo-io/mcp-in-docker

3.1

If you are the rightful owner of mcp-in-docker and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Model Context Protocol (MCP) server facilitates communication between large language models (LLMs) and tools using a standardized protocol, offering both REST API and WebSocket interfaces.

Model Context Protocol Server

A containerized Model Context Protocol (MCP) server that enables communication between LLMs and tools through a standardized protocol. The server provides both REST API and WebSocket interfaces for tool execution and context management.

Features

  • Dual runtime environment (Node.js + Python)
  • WebSocket support for real-time updates
  • REST API endpoints for tool management
  • Context persistence and management
  • Tool execution isolation
  • Easy deployment with Docker
  • Support for Python-based tools

Prerequisites

  • Docker
  • Docker Compose

Setup

  1. Clone the repository:
git clone <repository-url>
cd eooo-mcp-docker
  1. Create necessary directories:
mkdir -p tools context data
  1. Configure environment variables by creating a .env file:
NODE_ENV=production
PORT=3000
TOOLS_DIR=/app/tools
CONTEXT_DIR=/app/context
PYTHON_PATH=/usr/local/bin/python

Running the Server

  1. Build and start the container:
docker-compose up --build
  1. To run in detached mode:
docker-compose up -d

API Endpoints

REST API

  • GET /api/tools: List all available tools
  • POST /api/execute: Execute a specific tool
  • GET /api/context/:id: Retrieve context by ID

WebSocket API

Connect to ws://localhost:3000 and send/receive JSON messages:

Messages
  1. Execute Tool:
{
  "type": "EXECUTE_TOOL",
  "payload": {
    "tool": "tool_name.py",
    "params": {
      "param1": "value1"
    }
  }
}
  1. Get Context:
{
  "type": "GET_CONTEXT",
  "payload": "context_id"
}

Tool Integration

  1. Place your Python tools in the tools directory
  2. Tools should accept JSON parameters and return JSON output
  3. Example tool structure:
import sys
import json

def main(params):
    # Process params
    result = {"status": "success", "data": {}}
    return json.dumps(result)

if __name__ == "__main__":
    params = json.loads(sys.argv[1])
    print(main(params))

Context Management

  1. Context files are stored in the context directory as JSON files
  2. Each context file should have a unique ID
  3. Context can be accessed via both REST API and WebSocket

Development

To run in development mode with hot reload:

docker-compose up --build

Stopping the Server

docker-compose down

Security Considerations

  1. Tool execution is isolated within the container
  2. Input validation is performed on all API endpoints
  3. Context access can be restricted based on implementation needs

License

[Your License Here]