Skip to main content

Semantic MCP

PyPI version Docker

Semantic router for MCP ecosystems - Discover, manage, and execute tools across multiple MCP servers with progressive disclosure.

Overview

semantic-mcp is a FastMCP-based MCP server that provides semantic discovery and lifecycle management for other MCP servers. It connects to a discovery service for semantic search and manages server lifecycles locally via ZMQ-based IPC.

LLM Client (Claude/Cline)
    │ MCP Protocol
    ▼
┌─────────────────────────────┐
│       semantic-mcp          │
│    (FastMCP MCP Server)     │
├─────────────────────────────┤
│  Discovery → Semantic API   │
│  Execution → ZMQ + Sessions │
└─────────────────────────────┘
    │               │
    ▼               ▼
Discovery       MCP Servers
Service         (stdio/http)

Installation

uvx semantic-mcp serve --transport stdio

Option 2: pip/uv

# Install from PyPI
pip install semantic-mcp

# Or with uv
uv pip install semantic-mcp

# Run
semantic-mcp serve --transport stdio

Option 3: Docker

docker pull milkymap/semantic-mcp:0.2

docker run -d \
  -p 8001:8001 \
  -e DISCOVERY_URL=http://your-discovery-service \
  -e DISCOVERY_API_KEY=your-key \
  milkymap/semantic-mcp:0.2 serve --transport streamable-http --port 8001

Option 4: From source

git clone https://github.com/milkymap/mcp_runtime
cd mcp_runtime
uv sync
uv run semantic-mcp serve

Configuration

Environment Variables

Variable Description Default
DISCOVERY_URL Discovery service API URL http://localhost:8000
DISCOVERY_API_KEY API key for discovery authentication None
DISCOVERY_ENCRYPTION_KEY Key to decrypt sensitive env vars in server configs None
TOOL_OFFLOADED_DATA_PATH Path for large result offloading /tmp/mcp_offloaded
MAX_RESULT_TOKENS Max tokens before content offloading 4096
BACKGROUND_QUEUE_SIZE Max background tasks in queue 100
OPENAI_API_KEY OpenAI API key (for image descriptions) None

MCP Client Integration

Claude Code / Cline (uvx)

Add to your .mcp.json or MCP config:

{
  "mcpServers": {
    "semantic-mcp": {
      "command": "uvx",
      "args": ["semantic-mcp", "serve", "--transport", "stdio"],
      "env": {
        "DISCOVERY_URL": "https://your-discovery-service",
        "DISCOVERY_API_KEY": "your-api-key"
      }
    }
  }
}

Claude Desktop (Docker)

{
  "mcpServers": {
    "semantic-mcp": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "DISCOVERY_URL", "-e", "DISCOVERY_API_KEY",
        "--add-host=host.docker.internal:host-gateway",
        "milkymap/semantic-mcp:0.2", "serve", "--transport", "stdio"
      ],
      "env": {
        "DISCOVERY_URL": "http://host.docker.internal:8000",
        "DISCOVERY_API_KEY": "your-key"
      }
    }
  }
}

Remote HTTP Server

Start the server:

semantic-mcp serve --transport streamable-http --host 0.0.0.0 --port 8001

Client configuration:

{
  "mcpServers": {
    "semantic-mcp": {
      "url": "http://your-server:8001/mcp"
    }
  }
}

Available Operations

semantic-mcp exposes a single semantic_router tool with these operations:

Discovery (lightweight)

Operation Description
search_tools Search for tools using natural language
search_servers Search for servers using natural language
list_servers List all registered servers
get_server_tools List tools on a server
get_statistics Get server/tool counts

Exploration (full details)

Operation Description
get_server_info Get detailed server information
get_tool_details Get full tool schema and description

Lifecycle

Operation Description
manage_server Start or shutdown a server
list_running_servers List currently running servers

Execution

Operation Description
execute_tool Execute a tool on a running server
poll_task_result Check background task status
cancel_task Cancel a running background task
list_tasks List all background tasks
get_content Retrieve offloaded content by reference ID

Workflow

1. DISCOVER    search_tools("your need")         → Find relevant tools
       ↓
2. EXPLORE     get_server_info(server)           → Check capabilities
               get_server_tools(server)          → List available tools
       ↓
3. UNDERSTAND  get_tool_details(server, tool)    → Get full schema (REQUIRED)
       ↓
4. START       manage_server(server, "start")    → Start the MCP server
       ↓
5. EXECUTE     execute_tool(server, tool, args)  → Run the tool
       ↓
6. CLEANUP     manage_server(server, "shutdown") → Stop when done (optional)

Important rules:

  • Always call get_tool_details before execute_tool to understand the schema
  • Always call manage_server(start) before executing tools
  • Use in_background=true for long-running operations, then poll_task_result
  • Large responses are automatically offloaded; use get_content(ref_id) to retrieve

Architecture

Component Description
RuntimeEngine Core runtime managing ZMQ communication and server lifecycle
DiscoveryClient HTTP client for discovery service API
ContentManager Large result offloading (text chunking, images)
BackgroundTasks Priority queue for async tool execution
FastMCP MCP server framework exposing tools to LLMs

Development

# Install with dev dependencies
uv sync --group dev

# Run tests
uv run pytest tests/ -v

License

MIT

Metadata

Release files for semantic-mcp 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for semantic-mcp 0.2.1
File Size Uploaded Provenance
semantic_mcp-0.2.1.tar.gz 17.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for semantic-mcp 0.2.1
File Interpreter ABI Platform
semantic_mcp-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 47.6 kB

Release files / semantic_mcp-0.2.1.tar.gz

Download URL semantic_mcp-0.2.1.tar.gz
Size 17.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0110143de4070adef1bb68b81ceb0e6117d349482af586fed78dd237e8dc08f5
BLAKE2b-256 checksum
How to use checksums
612c5d05ea914f6b5de0ceb302ff7ecd0b0b433aa4f029d4817a8b9d1cc76f8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release files / semantic_mcp-0.2.1-py3-none-any.whl

Download URL semantic_mcp-0.2.1-py3-none-any.whl
Size 29.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef55849418576263bc461dcac5326bc8c332024aa5bc1246be8ae901b799d4be
BLAKE2b-256 checksum
How to use checksums
147180ab5b2864d51159b3799cb53b6e7891e39cb7136ed3cbb8ce4c18241f03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Security for semantic-mcp 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page