
Test-DH-MCP
Explorez la création d'un serveur MCP de DeepHaven Core
3 years
Works with Finder
0
Github Watches
0
Github Forks
0
Github Stars
test-dh-mcp
This project demonstrates how to define and run an MCP (Multi-Channel Protocol) server using the FastMCP implementation. It includes examples for tool registration, server/client usage, and integration with Claude Desktop and MCP Inspector.
Project Structure
-
src/mcp_server.py
— Main entrypoint to run the MCP server (configurable for SSE or stdio transport). -
src/dhmcp/__init__.py
— All tools are registered here using the@mcp_server.tool()
decorator. -
src/mcp_client.py
— Example async client for testing tools. -
requirements.txt
— Python dependencies (includingmcp[cli]
andautogen-ext
).
Using uv
for Dependency Management
uv
is a modern, ultra-fast Python package manager and runner. It can be used as a drop-in replacement for pip and venv, providing faster installs and improved dependency management.
Key Concepts
-
pyproject.toml
: The modern, recommended way to specify your project's dependencies and metadata. uv uses this as the source of truth. -
requirements.txt
: Supported for compatibility with traditional Python tools and workflows. Optional if you usepyproject.toml
. -
uv.lock
: Lockfile for reproducible installs (auto-managed by uv).
Modern Workflow (Recommended)
-
Add dependencies directly to your project:
This updatesuv pip install <package> # Example: uv pip install autogen-ext mcp[cli]
pyproject.toml
anduv.lock
. -
Sync environment:
uv pip install # Installs all dependencies from pyproject.toml
-
Run scripts:
uv run src/mcp_server.py uv run src/mcp_client.py
Compatibility Workflow (requirements.txt)
- If you have an existing
requirements.txt
, you can use:uv pip install -r requirements.txt # or uv add --requirements requirements.txt
- This will sync dependencies and update your lockfile. You can keep both files in sync for maximum compatibility.
Notes
-
requirements.txt
is optional with uv. For new projects, you can rely entirely onpyproject.toml
anduv.lock
. - For legacy projects or sharing with users of pip, keep
requirements.txt
up to date. -
uv
works with or without a virtual environment. Useuv venv .venv
to create one if desired. - If you have multiple environments, use
--active
to target the currently activated one.
Quick Start: Server
1. Install dependencies
It is recommended to use a virtual environment:
- Using
venv
:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- Using
uv
:
uv pip install -r requirements.txt
2. Run the MCP Server
From the project root, run (choose the transport that fits your use case):
-
SSE transport (default, for browser/web clients):
python src/mcp_server.py # or, explicitly: python src/mcp_server.py --transport sse # or, using uv: uv run src/mcp_server.py
The server will listen on http://localhost:8000/sse
-
Stdio transport (recommended for Claude Desktop/Inspector):
python src/mcp_server.py --transport stdio # or, using uv: uv run src/mcp_server.py --transport stdio
The server will communicate via stdio (no HTTP port needed).
You should see log output indicating the server is running with the selected transport.
Quick Start: Client
Note: The Python client (
mcp_client.py
) requires the MCP server to be running in SSE mode (the default). It will not work if the server is running in stdio mode.
1. Install dependencies
It is recommended to use a virtual environment:
- Using
venv
:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- Using
uv
:
uv pip install -r requirements.txt
2. Run the MCP Client
From the project root, run:
- Using
venv
:
cd src
python -m mcp_client
- Using
uv
:
cd src
uv run mcp_client.py
You should see log output indicating the client is running and listing available tools.
Claude Desktop
You can connect Claude Desktop to your local stdio MCP server to use custom tools.
-
Edit
~/Library/Application\ Support/Claude/claude_desktop_config.json
:- Using
venv
:
{ "mcpServers": { "test-dh-mcp": { "command": "/Users/chip/dev/test-dh-mcp/.venv/bin/python3", "args": ["/Users/chip/dev/test-dh-mcp/src/mcp_server.py", "--transport", "stdio"] } } }
- Using
uv
:
{ "mcpServers": { "test-dh-mcp": { "command": "uv", "args": [ "--directory", "/Users/chip/dev/test-dh-mcp/src", "run", "mcp_server.py", "--transport", "stdio" ] } } }
- Using
-
Restart Claude Desktop.
-
Debugging logs can be found in
~/Library/Logs/Claude/
Registering Tools
Define new tools in dhmcp/__init__.py
using the @mcp_server.tool()
decorator. Example:
@mcp_server.tool()
def echo_tool(message: str) -> str:
"""
Echo tool that returns the input message prefixed with 'Echo:'.
"""
return f"Echo: {message}"
Troubleshooting
- Ensure you are running commands from the correct directory (
src
for direct script execution). - If you change tool definitions, restart the server.
- For connection issues, check that the server is running and listening on the expected address/port (for SSE), or correctly attached via stdio (for Claude/Inspector).
Is the server running?
-
SSE mode:
curl http://localhost:8000/sse
-
Stdio mode:
- Check your Claude/Inspector logs for successful connection and tool listing.
MCP Inspector
The MCP Inspector is a tool that allows you to inspect the state of an MCP server.
-
Install the MCP Inspector:
npm install -g @modelcontextprotocol/inspector
-
Run the MCP Inspector:
-
** SSE mode: **
- Using
venv
:
cd /Users/chip/dev/test-dh-mcp/src npx @modelcontextprotocol/inspector \ /Users/chip/dev/test-dh-mcp/venv/bin/python3 mcp_server.py --transport sse
- Using
uv
:
cd /Users/chip/dev/test-dh-mcp/src npx @modelcontextprotocol/inspector \ uv run mcp_server.py --transport sse
- Using
-
** Stdio mode: **
- Using
venv
:
cd /Users/chip/dev/test-dh-mcp/src npx @modelcontextprotocol/inspector \ /Users/chip/dev/test-dh-mcp/venv/bin/python3 mcp_server.py --transport stdio
- Using
uv
:
cd /Users/chip/dev/test-dh-mcp/src npx @modelcontextprotocol/inspector \ uv run mcp_server.py --transport stdio
- Using
-
相关推荐
🔥 1Panel fournit une interface Web intuitive et un serveur MCP pour gérer des sites Web, des fichiers, des conteneurs, des bases de données et des LLM sur un serveur Linux.
🧑🚀 全世界最好的 LLM 资料总结 (数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Résumé des meilleures ressources LLM du monde.
⛓️RULEGO est un cadre de moteur de règle d'orchestration des composants de nouvelle génération légère, intégrée, intégrée et de nouvelle génération pour GO.
PDF Traduction de papier scientifique avec formats conservés - 基于 AI 完整保留排版的 PDF 文档全文双语翻译 , 支持 Google / Deepl / Olllama / Openai 等服务 , 提供 CLI / GUI / MCP / DOCKER / ZOTERO
Créez facilement des outils et des agents LLM à l'aide de fonctions Plain Bash / JavaScript / Python.
😎简单易用、🧩丰富生态 - 大模型原生即时通信机器人平台 | 适配 QQ / 微信 (企业微信、个人微信) / 飞书 / 钉钉 / Discord / Telegram / Slack 等平台 | 支持 Chatgpt 、 Deepseek 、 Dify 、 Claude 、 GEMINI 、 XAI 、 PPIO 、 OLLAMA 、 LM Studio 、阿里云百炼、火山方舟、 Siliconflow 、 Qwen 、 Moonshot 、 ChatGlm 、 Sillytraven 、 MCP 等 LLM 的机器人 / Agent | Plateforme de bots de messagerie instantanée basés sur LLM, prend en charge Discord, Telegram, WeChat, Lark, Dingtalk, QQ, Slack
Reviews

user_ea88unDA
As a dedicated user of test-dh-mcp, I am thoroughly impressed with its seamless integration and user-friendly interface. Created by the talented chipkent, this application has significantly streamlined my workflow. Although there are no specific product details available in the description, I highly recommend giving it a try based on my positive experience.

user_N2wYM7Wx
As a loyal user of the test-dh-mcp application, I am highly impressed with its performance and user-friendly interface. Developed by chipkent, this tool stands out for its reliability and efficiency. It significantly enhances my workflow, and I would highly recommend it to anyone looking for a robust MCP application.

user_8hHk4GtB
As a loyal user of test-dh-mcp, I must commend chipkent for creating such a fantastic application. It is incredibly user-friendly and efficient, meeting all my needs seamlessly. This product stands out in its category and has made my workflow much more streamlined. Highly recommend it!

user_bSzJMv0G
As an avid user of test-dh-mcp, I have been thoroughly impressed by its performance and reliability. Developed by the talented chipkent, this application has significantly streamlined my workflow. Highly recommended for anyone seeking efficiency and precision.

user_oj24SenY
I've been using test-dh-mcp by chipkent for a while now, and it's truly a game-changer. The seamless integration and intuitive design make it stand out. Highly recommended for anyone looking to improve their workflow!