Set up your environment
Use Python 3.12 and create a virtual environment:COMPOSIO_EXAMPLES_USER_ID identifies this demo’s Composio user. In your application, use your signed-in user’s ID.
Run the agent
Choose one framework and install its dependencies. Each script creates the session, runs the lookup, and deletes the session when the run finishes or raises an error.- CrewAI
- LangChain
Install Composio, CrewAI, and its MCP dependency:Save this as Run it:The repository’s CrewAI MCP example uses the same connection pattern to summarize Gmail. That variant needs a connected Gmail account.
crewai_agent.py. CrewAI’s MCPServerHTTP accepts the session’s URL and headers through the agent’s mcps list.crewai_agent.py
Check the result
The agent printspg’s current karma, a short bio when the profile contains one, and the Hacker News profile URL. Values and wording vary between runs. Check that the response cites https://news.ycombinator.com/user?id=pg and uses the tool’s result.
The direct tools preset exposes HACKERNEWS_GET_USER directly. The agent doesn’t need to search for tools or start an authentication flow. To research another Hacker News user, change pg in the prompt and source URL.
If the MCP connection returns an authentication error, check COMPOSIO_API_KEY and pass both session.mcp.url and session.mcp.headers. Re-run the script to create a fresh session; the previous run’s session was deleted.