feat(mcp): add mcp_paths.toml for multi-project access
- Add mcp_paths.toml with extra_dirs for C:/projects/gencpp - Update mcp_server.py to read allowed_paths from mcp_paths.toml
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
[allowed_paths]
|
||||
extra_dirs = [
|
||||
"C:/projects/gencpp",
|
||||
]
|
||||
+11
-2
@@ -79,9 +79,18 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
|
||||
return [TextContent(type="text", text=f"ERROR: {e}")]
|
||||
|
||||
async def main() -> None:
|
||||
# Configure mcp_client with the project root so py_* tools are not ACCESS DENIED
|
||||
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
mcp_client.configure([], extra_base_dirs=[project_root])
|
||||
|
||||
extra_dirs = [project_root]
|
||||
mcp_paths_toml = os.path.join(project_root, "mcp_paths.toml")
|
||||
if os.path.exists(mcp_paths_toml):
|
||||
import tomllib
|
||||
with open(mcp_paths_toml, "rb") as f:
|
||||
config = tomllib.load(f)
|
||||
allowed = config.get("allowed_paths", {}).get("extra_dirs", [])
|
||||
extra_dirs.extend(allowed)
|
||||
|
||||
mcp_client.configure([], extra_base_dirs=extra_dirs)
|
||||
async with stdio_server() as (read_stream, write_stream):
|
||||
await server.run(
|
||||
read_stream,
|
||||
|
||||
Reference in New Issue
Block a user