Logo Smart MCP Proxy

Smart MCP Proxy

Cộng đồng
Dumbris

To use mcpproxy in Cursor IDE, add this configuration to your ~/.cursor/mcp.json:

Nhà phát hànhDumbris
Kho mãmcpproxy
Ngôn ngữPython
Bản fork
11
Sao
39
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    Smart MCP Proxy cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    39 sao và 11 bản fork từ kho mã được liên kết.

Smart MCP Proxy

PyPI version License: MIT Python 3.11+

Smart MCP Proxy Demo

Quick Start

install with pip:

bash
pip install smart-mcp-proxy

Cursor IDE Integration

To use mcpproxy in Cursor IDE, add this configuration to your ~/.cursor/mcp.json:

json
{
  "mcpServers": {
    "mcp-proxy": {
      "command": "mcpproxy",
      "env": {
        "MCPPROXY_CONFIG_PATH": "/Users/user/.cursor/mcp_proxy.json"
      }
    }
  }
}

Then create a separate ~/.cursor/mcp_proxy.json with your actual(!) MCP servers: (just an example of configuration, you can use any MCP servers you want)

json
{
  "mcpServers": {
    "company-mcp": {
      "command": "uvx",
      "args": ["--from", "mcp-company-python@git+https://github.com/company/mcp-company.git", "company-mcp-server"],
      "env": {
        "COMPANY_TOKEN": "${COMPANY_TOKEN}",
        "PORT": "9090"
      }
    },
    "company-docs": {
      "url": "http://localhost:8000/mcp/"
    }
  }
}

Important: The mcp_proxy.json must be a different file than mcp.json to avoid circular proxy connections. The proxy configuration file has the same format as Cursor's MCP configuration but contains the actual MCP servers you want to federate.

Google ADK Integration

To use mcpproxy with Google ADK, you can integrate it using the MCPToolset:

python
from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioServerParameters

proxy_tool = MCPToolset(
    connection_params=StdioServerParameters(
        command="mcpproxy",
        args=[],
        env={"MCPPROXY_CONFIG_PATH": "/Users/user/.cursor/mcp_proxy.json"}
    )
)

Tip for better LLM results (copy-paste into your system/dev prompt):

When you see a tool named `retrieval_tools` in the MCP tool list, call it first.  
It returns the most relevant tools for the user’s request, helping you answer more accurately and concisely.

A federating gateway that sits between AI agents and multiple Model Context Protocol (MCP) servers, providing intelligent tool discovery and dynamic registration.

🌐 Website: mcpproxy.app 📦 PyPI: pypi.org/project/smart-mcp-proxy 🔗 GitHub: github.com/Dumbris/mcpproxy

Features

  • Flexible Routing Strategies: Two modes - DYNAMIC (tools registered on-demand) or CALL_TOOL (proxy-only execution)
  • Dynamic Tool Discovery: Automatically discovers tools from multiple MCP servers
  • Intelligent Search: Uses configurable embedding backends (BM25, HuggingFace, OpenAI) to find relevant tools
  • One-Click Tool Access: Single retrieve_tools function that searches, registers, and exposes the top 5 most relevant tools
  • FastMCP Integration: Built on FastMCP v2 for robust server runtime and client capabilities
  • Persistent Indexing: SQLite + Faiss storage for fast tool lookup and change detection
  • MCP Spec Compliant: Emits proper notifications/tools/list_changed events
  • Flexible Dependencies: Optional dependencies for different backends to minimize install size

Architecture

┌─────────────────┐    ┌─────────────────────────────────┐    ┌─────────────────┐
│   AI Agent      │───▶│     Smart MCP Proxy             │───▶│  MCP Servers    │
│                 │    │                                 │    │                 │
│ retrieve_tools()│    │ ┌─────────────┐ ┌─────────────┐ │    │ • company-prod  │
│                 │    │ │   Indexer   │ │ Persistence │ │    │ • company-docs  │
│ tool_1()        │◀───│ │   (BM25/    │ │  (SQLite +  │ │    │ • oauth-server  │
│ tool_2()        │    │ │ HF/OpenAI)  │ │   Faiss)    │ │    │ • ...           │
│ ...             │    │ └─────────────┘ └─────────────┘ │    │                 │
└─────────────────┘    └─────────────────────────────────┘    └─────────────────┘

Quick Start

1. Installation

Choose your installation based on the embedding backend you want to use:

bash
# Basic installation with BM25 (lexical search, no ML dependencies)
pip install smart-mcp-proxy

# Or with specific backends:
pip install smart-mcp-proxy[bm25]         # Explicit BM25 (same as basic)
pip install smart-mcp-proxy[huggingface]  # HuggingFace + vector search
pip install smart-mcp-proxy[openai]       # OpenAI embeddings + vector search
pip install smart-mcp-proxy[all]          # All backends available

# Development install
git clone https://github.com/Dumbris/mcpproxy.git
cd mcpproxy
pip install -e .[all]

The proxy will automatically check for required dependencies and provide helpful error messages if you try to use a backend without the required packages installed.

2. Start the Proxy

bash
# Using the installed script
MCPPROXY_CONFIG_PATH=mcp_config.json mcpproxy

The proxy will:

  1. Discover tools from all configured MCP servers
  2. Index them using the chosen embedding backend
  3. Start MCP server, by default transport is stdio, you can use MCPPROXY_TRANSPORT to change it to streamable-http or sse

Routing Strategies

Smart MCP Proxy supports two routing strategies:

DYNAMIC Mode

  • Behavior: AI agent calls retrieve_tools, which searches and dynamically registers the most relevant tools as MCP tools
  • Tool Registration: Tools become available in the MCP protocol after retrieve_tools call
  • Client View: Sees both retrieve_tools and the registered tools (e.g., company_create_user, storage_upload_file)
  • Use Case: Best for clients that can handle dynamic tool registration and notifications

CALL_TOOL Mode (Default)

  • Behavior: AI agent calls retrieve_tools to discover tools, then uses call_tool to execute them
  • Tool Registration: No dynamic registration - tools are executed through the proxy
  • Client View: Only sees retrieve_tools and call_tool tools
  • Use Case: Better for clients with tool registration limits or simpler tool management
bash
# Set routing strategy
export MCPPROXY_ROUTING_TYPE=DYNAMIC    # or CALL_TOOL (default)

Output Truncation

To prevent context bloating from large tool outputs, you can configure output truncation:

bash
# Truncate tool outputs to 2000 characters (disabled by default)
export MCPPROXY_TRUNCATE_OUTPUT_LEN=2000

When enabled, outputs exceeding the limit are truncated showing:

  • First portion of the output
  • <truncated by smart mcp proxy> marker
  • Last 50 characters of the output

This helps manage token usage while preserving both the beginning and end of outputs.

Usage

Cursor IDE

See example on the top of the README.md file.

For AI Agents

DYNAMIC Mode Usage:

  1. Call retrieve_tools("user management")
  2. Use the returned tools directly (e.g., company_create_user)

CALL_TOOL Mode Usage:

  1. Call retrieve_tools("user management")
  2. Call call_tool("company_create_user", {"name": "john", "email": "john@example.com"})

Programmatic Usage

python
from mcpproxy import SmartMCPProxyServer

proxy = SmartMCPProxyServer("config.json")
await proxy.start()

# Use the indexer directly
results = await proxy.indexer.search_tools("delete volume", k=3)
for result in results:
    print(f"{result.tool.name}: {result.score}")

Project Structure

mcpproxy/
├── models/
│   └── schemas.py           # Pydantic models and schemas
├── persistence/
│   ├── db.py               # SQLite operations
│   ├── faiss_store.py      # Faiss vector storage
│   └── facade.py           # Unified persistence interface
├── indexer/
│   ├── base.py             # Base embedder interface
│   ├── bm25.py             # BM25 implementation
│   ├── huggingface.py      # HuggingFace embeddings
│   ├── openai.py           # OpenAI embeddings
│   └── facade.py           # Search and indexing interface
├── server/
│   ├── config.py           # Configuration management
│   └── mcp_server.py       # FastMCP server implementation
└── utils/
    └── hashing.py          # SHA-256 utilities for change detection

Environment Variables

VariableValuesDefaultDescription
MCPPROXY_ROUTING_TYPEDYNAMIC, CALL_TOOLCALL_TOOLTool routing strategy
MCPPROXY_EMBEDDERBM25, HF, OPENAIBM25Embedding backend
MCPPROXY_HF_MODELHuggingFace model namesentence-transformers/all-MiniLM-L6-v2HF model
MCPPROXY_TOP_KInteger5Number of tools to register
MCPPROXY_TOOLS_LIMITInteger15Maximum number of tools in active pool
MCPPROXY_TOOL_NAME_LIMITInteger60Maximum tool name length
MCPPROXY_TRUNCATE_OUTPUT_LENInteger-Truncate tool output to prevent context bloating (disabled by default)
MCPPROXY_LIST_CHANGED_EXECShell command-External command to execute after tool changes (see Client Compatibility)
MCPPROXY_DATA_DIRDirectory path~/.mcpproxyDirectory for database and index files
MCPPROXY_CONFIG_PATHPath to config filemcp_config.jsonConfig file location
MCPPROXY_HOSTHost to bind127.0.0.1Server host
MCPPROXY_PORTPort to bind8000Server port
MCPPROXY_TRANSPORTTransport to usestdioTransport to use
MCPPROXY_LOG_LEVELLog levelINFOLogging level (DEBUG, INFO, WARNING, ERROR)
MCPPROXY_LOG_FILEFile path-Optional log file path
MCPPROXY_RESET_DATABooleanfalseReset all data (useful when dimensions change)

Client Compatibility

MCP Tool List Refresh Workaround

This is only needed for DYNAMIC routing mode. The default CALL_TOOL routing mode doesn't require MCPPROXY_LIST_CHANGED_EXEC since tools are not dynamically registered.

Some MCP clients (like Cursor IDE) don't properly handle the standard tools/list_changed notification when new tools are registered in DYNAMIC mode. As a temporary workaround, you can configure the proxy to execute an external command after tool changes to trigger client refresh.

For Cursor IDE

Set the MCPPROXY_LIST_CHANGED_EXEC environment variable to touch the MCP configuration file:

bash
# For macOS/Linux
export MCPPROXY_LIST_CHANGED_EXEC="touch $HOME/.cursor/mcp.json"

# For Windows (PowerShell)
$env:MCPPROXY_LIST_CHANGED_EXEC = "cmd /c copy `"$HOME\.cursor\mcp.json`" +,,"

This causes Cursor to detect the config file change and refresh its tool list.

How it Works

  1. When you call retrieve_tools, the proxy registers new tools
  2. Standard tools/list_changed notification is sent (proper MCP way)
  3. If MCPPROXY_LIST_CHANGED_EXEC is set, the command is executed asynchronously
  4. The command triggers the MCP client to refresh its tool list

Security Note

⚠️ Important: The command in MCPPROXY_LIST_CHANGED_EXEC is executed with shell privileges. Only use trusted commands and never set this variable to user-provided input.

When Not to Use

  • Your MCP client properly handles tools/list_changed notifications
  • You're using the proxy programmatically (not through an MCP client)
  • Security policies prohibit executing external commands

This feature is disabled by default and only executes when explicitly configured.

Contributing

We welcome contributions! Please see our GitHub repository for:

Development Setup

bash
git clone https://github.com/Dumbris/mcpproxy.git
cd mcpproxy
pip install -e .[dev,all]
pytest tests/

License

This project is licensed under the MIT License - see the LICENSE file for details.

Cài đặt

TypingMind
Yêu cầu:

Node.js 18+

{
  "mcpServers": {
    "dumbris-mcpproxy": {
      "command": "uvx",
      "args": [
        "smart-mcp-proxy"
      ]
    }
  }
}

Dùng MCP Smart MCP Proxy với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối Smart MCP Proxy, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm Smart MCP Proxy làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của Smart MCP Proxy.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "dumbris-mcpproxy": {
      "command": "npx",
      "args": [
        "-y",
        "smart-mcp-proxy"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của Smart MCP Proxy, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của Smart MCP Proxy.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng Smart MCP Proxy giúp tôi làm việc này không?
Smart MCP Proxy
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng Smart MCP Proxy.

Câu hỏi thường gặp

Máy chủ MCP Smart MCP Proxy dùng để làm gì?

Smart MCP Proxy là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP Smart MCP Proxy với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng Smart MCP Proxy với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP Smart MCP Proxy với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối Smart MCP Proxy, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP Smart MCP Proxy với TypingMind?

Smart MCP Proxy hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP Smart MCP Proxy cung cấp những công cụ nào trong TypingMind?

Smart MCP Proxy cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP Smart MCP Proxy không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu Smart MCP Proxy yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇