local-only server
The server can only run on the client’s local machine because it depends on local resources.
Integrations
Provides a framework for developing custom MCP tools in Python, with examples including a simple hello world tool. Supports defining tool schemas, handling requests, and implementing business logic.
Enables configuration of the tool through TOML files, specifically for defining command-line tool names and project metadata in the pyproject.toml file.
SouthAsia MCP Tool
這是一個基於 MCP (Model Control Protocol) 框架的工具開發模板。
工具名稱配置
如果您想要更改工具名稱(預設為 "southAsia"),需要修改以下位置:
src/southasia/server.py
中的常量配置:
pyproject.toml
中的命令行工具名稱(使用小寫):
- Cursor 配置文件中的工具名稱:
注意:
- 工具名稱區分大小寫
- 命令行工具名稱建議使用小寫
- 修改後需要重新安裝套件並重啟 Cursor
分支說明
main
: 主分支,包含完整的筆記管理工具實現empty
: 空白分支,僅包含基本框架和 Hello World 示例工具,適合開始新工具開發
安裝說明
- 創建並激活虛擬環境:
- 安裝開發版本:
- 在 Cursor 中配置 MCP 工具:
- 打開 Cursor 的設定檔案:
%USERPROFILE%\.cursor\mcp.json
- 添加以下配置:
- 打開 Cursor 的設定檔案:
- 重啟 Cursor 使配置生效
- 運行服務器(測試):
- 測試安裝:
- 在 Cursor 中輸入指令:
@southAsia hello_world
- 如果看到問候訊息,表示安裝成功
- 在 Cursor 中輸入指令:
專案結構
開發新工具
請參考 Tool_GUIDE.md
了解如何開發新的工具。基本步驟如下:
- 在
handlers
目錄下創建新的處理器文件 - 實現工具的處理邏輯
- 在
handle_list_tools()
中註冊工具 - 在
server.py
中導入和註冊處理器
Hello World 示例
hello_world.py
提供了一個簡單的示例工具實現:
這個示例展示了:
- 如何定義工具列表(
handle_list_tools
) - 如何處理工具調用(
handle_call_tool
) - 如何進行參數驗證和錯誤處理
開發建議
- 遵循模組化結構:
- 工具處理器放在
handlers/
目錄 - 如需要,可以添加模型到
models/
目錄 - 如需要,可以添加服務到
services/
目錄
- 工具處理器放在
- 代碼品質:
- 添加適當的錯誤處理
- 保持代碼結構清晰
- 添加詳細的註釋
- 使用類型提示
- 測試:
- 確保新功能正常工作
- 測試錯誤處理
- 驗證與現有功能的兼容性
注意事項
- 所有更改都需要重啟服務器才能生效
- 確保在虛擬環境中進行開發
- 遵循現有的模組化結構
- 保持代碼風格一致
相關文件
Tool_GUIDE.md
: 詳細的工具開發指南src/southasia/handlers/hello_world.py
: 示例工具實現src/southasia/server.py
: 服務器配置和工具註冊
You must be authenticated.
A template for building tools based on the Model Control Protocol (MCP) framework, providing a structured way to develop and integrate custom tools with Cursor.