MCP Powered AI Assistance

MCP Powered AI Assistance

Enables secure execution of Python code, SQL queries, and metric fetching through MCP with ephemeral Docker sandboxing.

Category
访问服务器

README

MCP Powered AI Assistance

A secure, standardised AI assistant on the Model Context Protocol: an OpenAI-driven LangGraph agent that can query databases, fetch metrics, and run Python — with every untrusted execution confined to an ephemeral Docker sandbox.

User ──▶ Client Gateway (LangGraph + OpenAI)
             │  MCP over SSE (remote) or stdio (local)
             ▼
        MCP Server (FastAPI + official MCP SDK)
             │  run_python · execute_sql · fetch_metrics
             ▼
        Ephemeral Docker sandbox (no network, read-only,
        cpu/mem/pid quotas, hard timeout, orphan reaper)

State: Postgres (LangGraph checkpointer) · Events: Redis pub/sub

Layout

  • server/tools.py — tool registry; Pydantic-typed schemas exposed at capability negotiation
  • server/sandbox.py — ephemeral Docker execution + orphan reaper
  • server/main.py — FastAPI app (SSE transport) and stdio entrypoint
  • client/gateway.py — MCP client + LangGraph function-calling loop
  • tests/ — protocol compliance, schema validation, sandbox security E2E

Quick start

uv sync
docker compose up -d postgres redis     # infra
uv run python -m server.main            # MCP server on :8000 (SSE at /sse)

export OPENAI_API_KEY=sk-...
uv run python -m client.gateway "How many run_python calls in the last hour?"

# or local stdio (no server process needed):
MCP_TRANSPORT=stdio uv run python -m client.gateway "print hello from the sandbox"

Tests (V&V)

uv run pytest
  • Protocol compliance — initialize, tools/list (schemas present), tools/call round-trip.
  • Schema validation — malformed payloads return actionable Pydantic errors to the LLM; the server never crashes.
  • Sandbox security (E2E) — injected malicious code attempting host env-var reads, directory traversal, network egress, and filesystem writes is blocked; runaway code is killed at the timeout; the reaper removes crash orphans.

Production deployment

# self-signed cert for local TLS testing (use real certs / cert-manager in prod)
mkdir -p deploy/certs && openssl req -x509 -newkey rsa:2048 -nodes -days 365 \
  -keyout deploy/certs/server.key -out deploy/certs/server.crt -subj "/CN=mcp"

MCP_API_KEY=$(openssl rand -hex 32) docker compose up --build
# clients connect to https://host:8443/sse with header X-Api-Key: <key>

Containerising the MCP server is the industry standard so AI-generated code never executes with raw host access. On Kubernetes: run the server as a Deployment, give sandboxes their own node pool or use a socketless runtime (Kata/gVisor) instead of mounting the Docker socket, front with an Ingress terminating TLS. On AWS ECS: one service for the server, sandbox tasks via RunTask with an isolated task security group, ALB + ACM for TLS.

Readiness checklist

  • [x] Network isolation — sandboxes run with network_disabled=True: no egress at all, including VPC metadata endpoints.
  • [x] Resource quotas — 256 MB memory (no swap), 0.5 CPU, 64 pids, read-only rootfs, 16 MB noexec tmpfs per sandbox.
  • [x] TLS & auth — Nginx reverse proxy enforcing HTTPS and X-Api-Key auth in front of the SSE endpoint.
  • [x] Ephemeral cleanup — containers force-removed after each run; background reaper kills anything labelled mcp-sandbox=1 older than 120 s.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选