import os
from dotenv import load_dotenv
from crewai import Agent, Task, Crew
from crewai_tools import MCPServerAdapter
# Load environment variables
load_dotenv()
# Streamable HTTP Server configuration for Observee
# Replace {your_client_id} with your actual client ID from the Observee dashboard
server_params = {
"url": "https://mcp.observee.ai/mcp?client_id={your_client_id}",
"transport": "streamable-http",
"headers": {
"Authorization": "Bearer {observee_api_key}" # Replace with your API key
}
}
# Example usage
with MCPServerAdapter(server_params) as mcp_tools:
print(f"Available tools: {[tool.name for tool in mcp_tools]}")
my_agent = Agent(
role="MCP Tool User",
goal="Utilize tools from an MCP server.",
backstory="I can connect to MCP servers and use their tools.",
tools=mcp_tools, # Pass the loaded tools to your agent
reasoning=True,
verbose=True
)
# Create a task to check email
email_task = Task(
description="Check my latest email",
expected_output="Details about the latest email including sender, subject, and a brief summary of the content",
agent=my_agent
)
# Create the crew
crew = Crew(
agents=[my_agent],
tasks=[email_task],
verbose=True
)
# Execute the crew
result = crew.kickoff()
print("\n--- Result ---")
print(result)