1+ #!/usr/bin/env python3
2+ """Test script to verify MCP schema fix"""
3+
4+ import os
5+ import sys
6+
7+ # Add the src directory to Python path
8+ sys .path .insert (0 , os .path .join (os .path .dirname (__file__ ), 'src' , 'praisonai-agents' ))
9+
10+ from dotenv import load_dotenv
11+ from praisonaiagents import Agent , MCP
12+
13+ # Load .env before importing anything else
14+ load_dotenv ()
15+
16+ # Define allowed directories for filesystem access
17+ allowed_dirs = [
18+ "/Users/praison/praisonai-package/src/praisonai-agents" ,
19+ ]
20+
21+ # Test with minimal example
22+ print ("Testing MCP filesystem agent..." )
23+
24+ try :
25+ # Use the correct pattern from filesystem MCP documentation
26+ filesystem_agent = Agent (
27+ instructions = """You are a helpful assistant that can interact with the filesystem.
28+ Use the available tools when relevant to manage files and directories.""" ,
29+ llm = "gpt-4o-mini" ,
30+ tools = MCP (
31+ command = "npx" ,
32+ args = ["-y" , "@modelcontextprotocol/server-filesystem" ] + allowed_dirs
33+ )
34+ )
35+
36+ print ("✓ Agent created successfully" )
37+ print ("✓ MCP tools loaded without schema errors" )
38+
39+ # Try to start the agent (this will validate the tool schemas)
40+ result = filesystem_agent .start ("List files in /Users/praison/praisonai-package/src/praisonai-agents directory using MCP list_files" )
41+ print ("✓ Agent executed successfully" )
42+ print (f"Result: { result } " )
43+
44+ except Exception as e :
45+ print (f"✗ Error: { e } " )
46+ import traceback
47+ traceback .print_exc ()
48+ sys .exit (1 )
49+
50+ print ("\n Test passed! The MCP schema fix is working correctly." )
0 commit comments