Skip to main content
Build an agent that reads a Hacker News profile and reports its current karma and bio. Choose CrewAI or LangChain below. Both agents use a Composio session that exposes one public, read-only tool over MCP, so you don’t need to connect a Hacker News account. The session supplies the MCP URL and authentication headers. Your framework handles tool discovery and execution through that endpoint.

Set up your environment

Use Python 3.12 and create a virtual environment:
Set your Composio project API key and OpenAI API key in this shell:
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.
Install Composio, CrewAI, and its MCP dependency:
Save this as crewai_agent.py. CrewAI’s MCPServerHTTP accepts the session’s URL and headers through the agent’s mcps list.
crewai_agent.py
Run it:
The repository’s CrewAI MCP example uses the same connection pattern to summarize Gmail. That variant needs a connected Gmail account.

Check the result

The agent prints pg’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.

Use the same pattern in your application

Keep the session for as long as the conversation needs it, then delete it. To use a toolkit that needs an account, authorize that toolkit before running the agent. For SDK modifiers or custom tools that run in your process, use the CrewAI provider or LangChain provider. Those features don’t run through a hosted MCP session.