femtowin commited on
Commit
69ebf5d
·
1 Parent(s): 9128c95

Simplify filesystem tool to only use current directory absolute path

Browse files
Files changed (1) hide show
  1. mcp_integration.py +12 -21
mcp_integration.py CHANGED
@@ -367,14 +367,11 @@ async def add_filesystem_tool(mcp_client: MCPBrainClient, workspace_paths: List[
367
 
368
  Args:
369
  mcp_client: The MCP client to add the tool to
370
- workspace_paths: List of paths to allow access to. Defaults to common workspace paths.
371
  """
372
  if workspace_paths is None:
373
- workspace_paths = [
374
- "/tmp",
375
- "/home/user/app",
376
- "."
377
- ]
378
 
379
  try:
380
  await mcp_client.add_mcp_server(
@@ -399,11 +396,8 @@ def create_filesystem_tool_factory(workspace_paths: List[str] = None):
399
  Async function that adds filesystem tool to an MCP client
400
  """
401
  if workspace_paths is None:
402
- workspace_paths = [
403
- "/tmp",
404
- "/home/user/app",
405
- "."
406
- ]
407
 
408
  async def add_to_client(mcp_client: MCPBrainClient):
409
  return await add_filesystem_tool(mcp_client, workspace_paths)
@@ -418,22 +412,19 @@ class MCPToolConfig:
418
  "type": "stdio",
419
  "command": "npx",
420
  "args": ["-y", "@modelcontextprotocol/server-filesystem"],
421
- "workspace_paths": [
422
- "/tmp",
423
- "/home/user/app",
424
- "."
425
- ]
426
  }
427
 
428
  @staticmethod
429
  def get_filesystem_config(workspace_paths: List[str] = None) -> Dict[str, Any]:
430
  """Get filesystem tool configuration"""
431
  config = MCPToolConfig.FILESYSTEM_DEFAULT.copy()
432
- if workspace_paths:
433
- config["workspace_paths"] = workspace_paths
434
- config["args"] = ["-y", "@modelcontextprotocol/server-filesystem"] + workspace_paths
435
- else:
436
- config["args"] = ["-y", "@modelcontextprotocol/server-filesystem"] + config["workspace_paths"]
 
437
  return config
438
 
439
 
 
367
 
368
  Args:
369
  mcp_client: The MCP client to add the tool to
370
+ workspace_paths: List of paths to allow access to. Defaults to current directory.
371
  """
372
  if workspace_paths is None:
373
+ import os
374
+ workspace_paths = [os.path.abspath(".")]
 
 
 
375
 
376
  try:
377
  await mcp_client.add_mcp_server(
 
396
  Async function that adds filesystem tool to an MCP client
397
  """
398
  if workspace_paths is None:
399
+ import os
400
+ workspace_paths = [os.path.abspath(".")]
 
 
 
401
 
402
  async def add_to_client(mcp_client: MCPBrainClient):
403
  return await add_filesystem_tool(mcp_client, workspace_paths)
 
412
  "type": "stdio",
413
  "command": "npx",
414
  "args": ["-y", "@modelcontextprotocol/server-filesystem"],
415
+ "workspace_paths": None # Will be set to current directory at runtime
 
 
 
 
416
  }
417
 
418
  @staticmethod
419
  def get_filesystem_config(workspace_paths: List[str] = None) -> Dict[str, Any]:
420
  """Get filesystem tool configuration"""
421
  config = MCPToolConfig.FILESYSTEM_DEFAULT.copy()
422
+ if workspace_paths is None:
423
+ import os
424
+ workspace_paths = [os.path.abspath(".")]
425
+
426
+ config["workspace_paths"] = workspace_paths
427
+ config["args"] = ["-y", "@modelcontextprotocol/server-filesystem"] + workspace_paths
428
  return config
429
 
430