20250223_mcp-client
Documentation
Model Context Provider (MCP)
Model Context Provider 是一個創新的 AI 開發工具,專門設計用於增強大型語言模型(LLMs)的上下文理解和工具使用能力。它提供了一個統一的介面,讓開發者能夠更有效地管理和使用各種 AI 模型及其相關工具。
什麼是 MCP?
MCP 的核心理念是「上下文增強」和「工具協調」。它通過以下方式來實現這一目標:
1. 上下文管理
2. 工具整合
3. 模型協調
主要特點
1. 智能上下文處理
- 自動管理上下文長度
- 智能摘要和重要信息保留
- 動態調整提示策略
2. 強大的工具生態
- 內建多種開發工具
- 可擴展的工具介面
- 自動工具鏈組合
3. 開發者友好
- RESTful API
- 圖形化介面
- 完整的開發文檔
- 豐富的示例
4. 企業級特性
- 高可用性設計
- 安全性控制
- 使用量監控
- 日誌追蹤
應用場景
1. 軟體開發
- 代碼審查和重構
- API 文檔生成
- 測試用例生成
- 除錯協助
2. 知識管理
- 文檔分析和總結
- 知識庫建立
- 資訊檢索和組織
3. 工作流自動化
- 自動化腳本生成
- 工作流程優化
- 任務協調
4. 研究與分析
- 數據分析
- 文獻研究
- 報告生成
安裝需求
安裝 UV
pip install uv安裝依賴
uv pip install fastapi uvicorn gradio google-generativeai ollama重新同步依賴項
uv sync設定 API 金鑰
OpenAI
SET OPENAI_API_KEY='your-api-key'Anthropic (選用)
SET ANTHROPIC_API_KEY='your-api-key'Google (選用)
SET GOOGLE_API_KEY='your-api-key'Ollama (選用)
SET OLLAMA_HOST='http://localhost:11434'使用方式
1. FastAPI Web 介面
啟動 Web API 伺服器:
python -m mcpcli.web --openai-key sk-xxx... --anthropic-key sk-ant-xxx... --google-key xxx...命令列參數
- --openai-key 指定 `OpenAI API` 金鑰
- --anthropic-key 指定 `Anthropic API` 金鑰
- --google-key 指定 `Google API` 金鑰
伺服器將在 `http://localhost:7860` 啟動,你可以使用 Swagger UI(`http://localhost:7860/docs`)來測試 API。
主要 API 端點:
- `/connect/{server_name}` - 連接到指定伺服器
- `/chat` - 發送聊天訊息
- `/tools` - 列出可用工具
- `/resources` - 列出可用資源
- `/prompts` - 列出可用提示
2. Gradio 圖形介面
啟動 Gradio 介面:
python -m mcpcli.web.gradio_app --openai-key sk-xxx... --anthropic-key sk-ant-xxx... --google-key xxx... --port 8082命令列參數
- --openai-key 指定 `OpenAI API` 金鑰
- --anthropic-key 指定 `Anthropic API` 金鑰
- --google-key 指定 `Google API` 金鑰
- --port 指定 `Gradio` 端口,預設為 `8082`
介面將在 `http://localhost:8082` 啟動,你可以使用圖形化介面來與模型互動。
使用步驟:
1. 連接伺服器:
2. 配置 AI 設定:
3. 開始對話:
3. cli介面
使用python執行
python -m mcpcli.cli --server github --provider ollama --model llama3.2 --openai-key sk-xxx... --anthropic-key sk-ant-xxx... --google-key xxx...使用uv執行
uv run mcp-cli --server github --provider ollama --model llama3.2命令列參數
- --server 指定伺服器名稱,預設為`github`
- --host 指定伺服器主機,預設為`127.0.0.1`
- --port 指定伺服器端口,預設為`8765`
- --openai-key 指定 `OpenAI API` 金鑰
- --anthropic-key 指定 `Anthropic API` 金鑰
- --google-key 指定 `Google API` 金鑰
- --provider 指定 AI 提供者(openai, anthropic, google, ollama),預設為 `openai`
- --model 指定`模型名稱`
- --config-file 指定配置文件路徑,預設為`server_config.json`
常見問題解決
1. 連接錯誤:
2. API 金鑰相關:
3. 工具調用失敗:
開發者指南
添加新的 AI 提供者
1. 在 `llm_client.py` 中添加新的提供者支援
2. 更新 Gradio 介面中的提供者選項
3. 確保正確處理新提供者的 API 響應
自定義工具
1. 在工具配置文件中添加新工具定義
2. 實現工具的具體功能
3. 更新工具文檔
注意事項
- API 金鑰安全:請勿在公共環境中暴露你的 API 金鑰
- 資源使用:注意監控 API 使用量,避免超出限額
- 錯誤處理:建議實作錯誤重試機制
- 日誌記錄:保持適當的日誌級別以便排查問題
貢獻指南
歡迎提交 Pull Request 來改進這個專案!請確保:
1. 代碼符合 PEP 8 規範
2. 添加適當的測試用例
3. 更新相關文檔
4. 提供清晰的提交信息
授權
本專案採用 MIT 授權條款 - 詳見 LICENSE 文件
Frequently asked questions
What is 20250223_mcp-client?
20250223_mcp-client is a Model Context Protocol (MCP) server listed in the TrackMCP directory.
How do I install 20250223_mcp-client?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is 20250223_mcp-client open source?
Yes — it is hosted on GitHub at https://github.com/Mark850409/20250223_mcp-client.
Related MCP tools
AWS MCP Servers — helping you get the most out of AWS, wherever you use MCP. Python-based implementation. Trusted by 6900+ developers.
A simple, secure MCP-to-OpenAPI proxy server Python-based implementation. Trusted by 3500+ developers. Trusted by 3500+ developers.
MCP server that interacts with Obsidian via the Obsidian rest API community plugin Python-based implementation. Trusted by 2300+ developers.
Default Configuration: MCP CLI defaults to using Ollama with the gpt-oss reasoning model for local, privacy-focused operation without requiring API keys.
Official MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
MCP server for long term agent memory with Mem0. Also useful as a template to get you started building your own MCP server with Python!
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP