mirror of
https://github.com/MervinPraison/PraisonAI.git
synced 2026-11-07 17:33:33 -10:00
Previously MCP("npx -y pkg", args=[...]) passed the whole string as the
executable, so the subprocess spawn silently failed and 0 tools were
discovered. Now the command string is split on whitespace regardless of
whether args are supplied, using the first token as the executable and
prepending the remaining tokens to any explicit args.
Also updates examples/python/mcp/filesystem-mcp.py to use the reliable
executable + args form.
Co-authored-by: MervinPraison <[email protected]>
18 lines
636 B
Python
18 lines
636 B
Python
from praisonaiagents import Agent, MCP
|
|
import os
|
|
|
|
# Define allowed directories for filesystem access
|
|
allowed_dirs = [
|
|
"/Users/username/Desktop",
|
|
"/path/to/other/allowed/dir"
|
|
]
|
|
|
|
# Pass the executable as the first token and the allowed directories as args
|
|
filesystem_agent = Agent(
|
|
instructions="""You are a helpful assistant that can interact with the filesystem.
|
|
Use the available tools when relevant to manage files and directories.""",
|
|
llm="gpt-4o-mini",
|
|
tools=MCP("npx", args=["-y", "@modelcontextprotocol/server-filesystem", *allowed_dirs])
|
|
)
|
|
|
|
filesystem_agent.start("List files in the allowed directories") |