import asyncio
import os
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.mcp import MCPTools, StreamableHTTPClientParams
from agno.utils.log import log_exception
mcp_access_token = os.environ["MCP_ACCESS_TOKEN"]
pipedream_project_id = os.environ["PIPEDREAM_PROJECT_ID"]
pipedream_environment = os.environ["PIPEDREAM_ENVIRONMENT"]
pipedream_external_user_id = os.environ["PIPEDREAM_EXTERNAL_USER_ID"]
server_params = StreamableHTTPClientParams(
url="https://remote.mcp.pipedream.net/v3",
headers={
"Authorization": f"Bearer {mcp_access_token}",
"x-pd-project-id": pipedream_project_id,
"x-pd-environment": pipedream_environment,
"x-pd-external-user-id": pipedream_external_user_id,
"x-pd-app-slug": "linkedin",
},
)
async def run_agent(task: str) -> None:
try:
async with MCPTools(
server_params=server_params,
transport="streamable-http",
timeout_seconds=20,
) as mcp:
agent = Agent(
model=OpenAIResponses(id="gpt-5.2"),
tools=[mcp],
markdown=True,
)
await agent.aprint_response(
input=task,
stream=True,
)
except Exception as e:
log_exception(f"Unexpected error: {e}")
if __name__ == "__main__":
asyncio.run(
run_agent("Check the Pipedream organization on LinkedIn and tell me about it")
)