Skip to content

Commit 1eb93e4

Browse files
committed
MCP file system fixes for mcp client and tool dispatcher
1 parent beeaecd commit 1eb93e4

3 files changed

Lines changed: 26 additions & 14 deletions

File tree

Project_Andrew/Andrew.rar

249 Bytes
Binary file not shown.

Project_Andrew/caios_mcp_client.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,27 +221,26 @@ def call(self, tool_name: str, arguments: Dict[str, Any]) -> Dict[str, Any]:
221221
tool_lower = tool_name.lower()
222222

223223
# Route to correct server
224-
if tool_lower in FS_TOOLS:
225-
if not self.fs_available():
226-
return _error_result(f"Filesystem MCP server not available at {self.fs_url}. "
227-
f"Start it with: npx @modelcontextprotocol/server-filesystem C:\\CAIOS")
228-
base = self.fs_url
229-
elif tool_lower in WIN_TOOLS:
224+
if tool_lower in WIN_TOOLS:
230225
if not self.win_available():
231-
return _error_result(f"windows-mcp not available at {self.win_url}. "
232-
f"Start it with: uvx windows-mcp serve --transport sse --host localhost --port 8000")
226+
return _error_result(
227+
f"windows-mcp not available at {self.win_url}. "
228+
f"Start it with: uvx windows-mcp serve --transport streamable-http --host localhost --port 8000"
229+
)
233230
base = self.win_url
234231
else:
235-
# Unknown tool — try filesystem first, then windows
236-
base = self.fs_url if self.fs_available() else self.win_url
232+
# FS_TOOLS and unknown tools — not handled by MCP
233+
return _error_result(
234+
f"Tool '{tool_name}' is not a windows-mcp tool. "
235+
f"File operations are handled by os_control.py via [TOOL:read_file] etc."
236+
)
237237

238238
rpc_result = _jsonrpc_call(
239239
base,
240240
'tools/call',
241241
{'name': tool_name, 'arguments': arguments},
242242
self._next_id(),
243243
)
244-
245244
return _parse_mcp_result(rpc_result)
246245

247246
# ── Convenience wrappers for common filesystem operations ──

Project_Andrew/tool_dispatcher.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#V06242026
1+
#V06252026
22
# =============================================================================
33
# PROJECT ANDREW – Tool Dispatcher
44
# Intercepts LLM output for structured tool calls and routes them to the
@@ -431,8 +431,8 @@ def _dispatch_mcp(self, tool_name: str, attrs: Dict) -> str:
431431

432432
# Map tag names to (mcp_tool_name, required_arg)
433433
route_map = {
434-
'mcp_read': ('read_file', 'path'),
435-
'mcp_list': ('list_directory', 'path'),
434+
'mcp_read': None, # → os_control.read_file
435+
'mcp_list': None, # → os_control (not implemented, use powershell)
436436
'mcp_write': ('write_file', 'path'),
437437
'mcp_search': ('search_files', 'path'),
438438
'mcp_powershell': ('powershell', 'command'),
@@ -450,6 +450,19 @@ def _dispatch_mcp(self, tool_name: str, attrs: Dict) -> str:
450450
if required_arg and required_arg not in mcp_args:
451451
return f'[TOOL RESULT] {tool_name}: missing required attr "{required_arg}"'
452452

453+
# mcp_read
454+
if tool_name == 'mcp_read':
455+
path = attrs.get('path', '')
456+
controller = self._get_controller()
457+
if controller:
458+
return _handle_read_file({'path': path}, controller)
459+
return '[TOOL RESULT] mcp_read: os_control not available'
460+
461+
# mcp_list
462+
if tool_name == 'mcp_list':
463+
cmd = f'Get-ChildItem "{attrs.get("path", "C:/CAIOS")}" | Select-Object Name'
464+
return _handle_mcp_win({'command': cmd}, 'mcp_powershell')
465+
453466
# mcp_write needs content attr too
454467
if tool_name == 'mcp_write' and 'content' not in mcp_args:
455468
return '[TOOL RESULT] mcp_write: missing required attr "content"'

0 commit comments

Comments
 (0)