ChukMCPServer

ChukMCPServer

A Python framework for building Model Context Protocol servers with decorator-based tools, zero-config deployment, and high performance.

Category
访问服务器

README

ChukMCPServer

The fastest, most developer-friendly MCP server framework for Python.

Build production-ready Model Context Protocol servers in minutes with decorator-based tools, zero-config deployment, and world-class performance.

PyPI Python Tests Coverage License

from chuk_mcp_server import tool, run

@tool
def add(a: int, b: int) -> int:
    """Add two numbers together."""
    return a + b

run()  # That's it! Server running on stdio

⚡ Quick Start

Installation

# Basic installation
pip install chuk-mcp-server

# With optional features
pip install chuk-mcp-server[google_drive]  # Google Drive OAuth

Your First Server (30 seconds)

Option 1: Use the scaffolder (recommended)

uvx chuk-mcp-server init my-server
cd my-server
uv run my-server

Option 2: Write it yourself (5 lines of code)

from chuk_mcp_server import tool, run

@tool
def greet(name: str) -> str:
    """Greet someone by name."""
    return f"Hello, {name}!"

run()

Option 3: Add to Claude Desktop (instant integration)

uvx chuk-mcp-server init my-server --claude
# Automatically adds to claude_desktop_config.json

Use with Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "my-server": {
      "command": "uv",
      "args": ["run", "my-server"]
    }
  }
}

Restart Claude Desktop - your tools are now available!

🚀 Why ChukMCPServer?

  • 🏆 World-Class Performance: 36,000+ requests/second, <3ms overhead
  • 📋 Full MCP 2025-11-25: Complete conformance with the latest MCP specification
  • 🤖 Claude Desktop Ready: Zero-config stdio transport
  • ⚡ Zero Configuration: Smart defaults detect everything automatically
  • 🔐 OAuth 2.1 Built-In: Full OAuth support with @requires_auth decorator
  • ☁️ Cloud Native: Auto-detects GCP, AWS, Azure, Vercel
  • 🔒 Type Safe: Automatic schema generation from Python type hints
  • 🏷️ Tool Annotations: read_only_hint, destructive_hint, idempotent_hint, open_world_hint
  • 📊 Structured Output: output_schema on tools with typed structuredContent responses
  • 🎨 Icons: Icons on tools, resources, prompts, and server info
  • 📦 Dual Transport: STDIO + Streamable HTTP (with GET SSE streams), both with bidirectional support
  • 🧩 Full Protocol Surface: Sampling, elicitation, progress, roots, subscriptions, completions, tasks, cancellation
  • 🛡️ Production Hardened: Rate limiting, request validation, graceful shutdown, thread safety, health probes
  • 🧪 ToolRunner: Test tools without transport overhead
  • 📄 OpenAPI: Auto-generated OpenAPI 3.1.0 spec at /openapi.json

📚 Documentation

Full documentation available at: https://IBM.github.io/chuk-mcp-server/

🎯 Core Features

Decorators for Everything

from chuk_mcp_server import tool, resource, resource_template, prompt, requires_auth

@tool(read_only_hint=True, idempotent_hint=True,
      output_schema={"type": "object", "properties": {"result": {"type": "integer"}}})
def calculate(x: int, y: int) -> dict:
    """Perform calculations with structured output."""
    return {"result": x + y}

@resource("config://settings",
          icons=[{"uri": "https://example.com/gear.svg", "mimeType": "image/svg+xml"}])
def get_settings() -> dict:
    """Access configuration."""
    return {"theme": "dark", "version": "1.0"}

@resource_template("users://{user_id}/profile")
def get_user_profile(user_id: str) -> dict:
    """Parameterized resource template (RFC 6570)."""
    return {"user_id": user_id, "name": "Example User"}

@prompt
def code_review(code: str, language: str) -> str:
    """Generate code review prompt."""
    return f"Review this {language} code:\n{code}"

@tool
@requires_auth()
async def publish_post(content: str, _external_access_token: str | None = None) -> dict:
    """OAuth-protected tool."""
    # Token automatically injected and validated
    ...

HTTP Mode for Web Apps

from chuk_mcp_server import ChukMCPServer

mcp = ChukMCPServer(
    name="my-api",
    description="My production API server",
    icons=[{"uri": "https://example.com/icon.png", "mimeType": "image/png"}],
    website_url="https://example.com",
)

@mcp.tool
async def process_data(data: str) -> dict:
    return {"processed": data}

mcp.run(host="0.0.0.0", port=8000)  # HTTP server

MCP Apps — Rich UI Views in Claude.ai

Render interactive charts, maps, tables, and more directly in Claude.ai using MCP Apps structured content.

from chuk_mcp_server import ChukMCPServer

mcp = ChukMCPServer(name="my-view-server", version="1.0.0")

@mcp.tool(
    name="show_chart",
    description="Show sales data as a chart.",
    meta={
        "ui": {
            "resourceUri": "ui://my-view-server/chart",
            "viewUrl": "https://chuk-mcp-ui-views.fly.dev/chart/v1",
        }
    },
)
async def show_chart(chart_type: str = "bar") -> dict:
    return {
        "content": [{"type": "text", "text": "Sales chart."}],
        "structuredContent": {
            "type": "chart",
            "version": "1.0",
            "title": "Q1 Sales",
            "chartType": chart_type,
            "data": [{"label": "Revenue", "values": [
                {"label": "Jan", "value": 4200},
                {"label": "Feb", "value": 5100},
                {"label": "Mar", "value": 4800},
            ]}],
        },
    }

mcp.run()

How it works:

  • meta.ui.resourceUri — a ui:// URI identifying the view
  • meta.ui.viewUrl — HTTPS URL serving the view's HTML/JS bundle
  • The server automatically registers an MCP resource at the resourceUri that fetches the HTML from viewUrl
  • The server automatically enables the experimental capability
  • Claude.ai reads the HTML via resources/read, renders it in an iframe, and passes structuredContent as the data payload

See examples/mcp_apps_view_example.py for a complete example.

Cloud Deployment (Auto-Detection)

# Same code works everywhere - cloud platform auto-detected!
from chuk_mcp_server import tool, run

@tool
def my_tool(x: int) -> int:
    return x * 2

run()  # Automatically adapts to GCP, AWS, Azure, Vercel, etc.

Server Composition (Mix Local & Remote Tools)

Combine multiple MCP servers into one unified interface. Import tools from local Python modules or remote servers (STDIO/HTTP/SSE):

# config.yaml
composition:
  import:
    # Local Python module
    - name: "echo"
      type: "module"
      module: "chuk_mcp_echo.server:echo_service"
      prefix: "echo"

    # Remote MCP server via STDIO
    - name: "fetch"
      type: "stdio"
      command: "uvx"
      args: ["mcp-server-fetch"]
      prefix: "fetch"

    # Remote MCP server via HTTP
    - name: "weather"
      type: "http"
      url: "https://api.weather.com/mcp"
      prefix: "weather"
from chuk_mcp_server import ChukMCPServer

mcp = ChukMCPServer("composed-server")
mcp.load_config("config.yaml")
mcp.run()  # All tools available under unified namespaces

What you get:

  • Module imports: Direct Python imports (fastest)
  • STDIO proxy: Connect to subprocess servers (uvx, npx, python -m)
  • HTTP proxy: Connect to remote HTTP MCP servers
  • Built-in resilience: Automatic timeouts, retries, circuit breakers (via chuk-tool-processor)
  • Unified namespace: Tools prefixed by source (e.g., fetch.fetch, echo.echo_text)

🏆 Performance

ChukMCPServer is built for high throughput:

  • 36,348 RPS peak throughput (performance test)
  • 39,261 RPS with max optimizations (ultra test)
  • <3ms overhead per tool call
  • 100% success rate under sustained load

See Performance Benchmarks for detailed results.

📖 Learn More

Real-World Examples

🤝 Contributing

Contributions welcome! See Contributing Guide for details.

📄 License

Apache 2.0 License - see LICENSE file for details.

🔗 Links

  • Documentation: https://IBM.github.io/chuk-mcp-server/
  • PyPI Package: https://pypi.org/project/chuk-mcp-server/
  • GitHub: https://github.com/IBM/chuk-mcp-server
  • Issues: https://github.com/IBM/chuk-mcp-server/issues
  • Model Context Protocol: https://modelcontextprotocol.io

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选