chore(mcp): MCP 服务器移入 MCP/ 目录,新增 .mcp.json 客户端配置
- git mv transpyc_mcp → MCP/transpyc_mcp;server.py ROOT 改为向上定位项目根(兼容新位置) - 新建项目根 .mcp.json:transpyc-tools 直接以 python MCP/transpyc_mcp/server.py 启动 - MCP/README.md 更新服务器路径与快速接入说明 - smoke test 通过:initialize/tools-list(14)/tp_read_ast 调用链路正常
This commit is contained in:
1 parent
8ce08493e8
commit
39228d5654
4 files changed
+24
-3
No files matched your search
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"mcpServers": {
|
||||
"transpyc-tools": {
|
||||
"command": "python",
|
||||
"args": ["MCP/transpyc_mcp/server.py"],
|
||||
"cwd": "D:\\Users\\TermiNexus\\Desktop\\TransPyC"
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -15,17 +15,18 @@
|
||||
| `README.md` | 本文件:总览与快速接入 |
|
||||
| `protocol.md` | MCP 协议规范:工具定义、执行约定、输出格式、安全约束 |
|
||||
| `tools/` | 各工具的 JSON schema(可选生成,供客户端加载) |
|
||||
| `transpyc_mcp/` | MCP 服务器实现(stdio,零依赖) |
|
||||
|
||||
## 快速接入
|
||||
|
||||
MCP 服务器(`transpyc-tools`)以 stdio 方式运行于项目根目录:
|
||||
项目根目录已创建 `.mcp.json`,客户端(IDE/工具)读取后自动注册 MCP 服务器 `transpyc-tools`(服务器代码位于 `MCP/transpyc_mcp/`,stdio 零依赖,也可手动 `python MCP/transpyc_mcp/server.py` 启动):
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"transpyc-tools": {
|
||||
"command": "python",
|
||||
"args": ["-m", "transpyc_mcp.server"],
|
||||
"args": ["MCP/transpyc_mcp/server.py"],
|
||||
"cwd": "D:\\Users\\TermiNexus\\Desktop\\TransPyC"
|
||||
}
|
||||
}
|
||||
|
||||
File renamed without changes.
@@ -24,7 +24,18 @@ from typing import Any, Callable
|
||||
# ---------------------------------------------------------------------------
|
||||
# 常量
|
||||
# ---------------------------------------------------------------------------
|
||||
_ROOT: str = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
def _find_root() -> str:
|
||||
"""向上定位项目根(含 Projectrans.py 的目录),兼容服务器位于 MCP/transpyc_mcp 下。"""
|
||||
d: str = os.path.dirname(os.path.abspath(__file__))
|
||||
while True:
|
||||
if os.path.isfile(os.path.join(d, "Projectrans.py")):
|
||||
return d
|
||||
parent: str = os.path.dirname(d)
|
||||
if parent == d:
|
||||
return d
|
||||
d = parent
|
||||
|
||||
_ROOT: str = _find_root()
|
||||
_TOOLS_JSON: str = os.path.join(_ROOT, 'MCP', 'tools', 'tools.json')
|
||||
_COMPILE_TIMEOUT: int = 300
|
||||
_RUN_TIMEOUT: int = 30
|
||||
Reference in new issue
Block a user