FunctorClient SDK
The FunctorClient SDK provides a high-level Python interface for interacting with the Functor MCP server.
Installation
# Install the SDKpip install functor-mcp-sdk# Or install from sourcepip install -e .
Basic Usage
from functor_mcp_sdk import FunctorClient, create_client# Create clientclient = create_client(server_url="http://localhost:8001",api_key="your-api-key")# Use context manager for automatic connection managementasync with client.session():# Basic operationsresult = await client.ingest(source_path="document.pdf",source_type="file",target_kg="KG_Demo")# Enhanced operationssmart_result = await client.execute_smart(query="What are the main topics?",enable_analytics=True)# Memory operationsawait client.episodic_add_episode(session_id="session_123",event_type="query",event_data={"query": "...", "response": "..."})
Enhanced Methods
Smart Query
result = await client.execute_smart(query="What are the latest developments in AI?",mode="auto",use_vector_bypass=False,enable_reranking=True,max_results=10,kg_filter=["KG_Technology", "KG_Research"],reranker_method="listwise",quality_threshold=0.7,enable_analytics=True,include_explanations=True)print(f"Answer: {result['answer']}")print(f"Routing confidence: {result['execution_metadata']['routing_confidence']}")
Enhanced SQL
result = await client.execute_enhanced_sql(query="Show me entities with most relationships",include_explanation=True,query_type="auto",output_format="summary",include_schema_info=True)print(f"SQL: {result['sql_query']}")print(f"Explanation: {result['explanation']}")
Enhanced Re-ranking
result = await client.rerank_smart(query="artificial intelligence fundamentals",documents=[{"content": "Machine learning algorithms...", "title": "ML Overview"},{"content": "Deep learning models...", "title": "DL Advances"}],method="listwise",quality_filter="auto",return_analytics=True)for doc in result['ranked_documents']:print(f"Rank {doc['rank']}: {doc['document']['title']} (Score: {doc['score']})")