Pipedream Slack
This example shows how to use the Slack Pipedream MCP server with Kern Agents.
Code
1"""2�� Pipedream Slack MCP34This example shows how to use Pipedream MCP servers (in this case the Slack one) with Kern Agents.561. Connect your Pipedream and Slack accounts: https://mcp.pipedream.com/app/slack72. Get your Pipedream MCP server url: https://mcp.pipedream.com/app/slack83. Set the MCP_SERVER_URL environment variable to the MCP server url you got above94. Install dependencies: uv pip install kern-ai mcp-sdk1011"""1213import asyncio14import os1516from kern.agent import Agent17from kern.models.openai import OpenAIResponses18from kern.tools.mcp import MCPTools19from kern.utils.log import log_exception2021mcp_server_url = os.getenv("MCP_SERVER_URL")222324async def run_agent(task: str) -> None:25 try:26 async with MCPTools(27 url=mcp_server_url, transport="sse", timeout_seconds=2028 ) as mcp:29 agent = Agent(30 model=OpenAIResponses(id="gpt-5.2"),31 tools=[mcp],32 markdown=True,33 )34 await agent.aprint_response(35 message=task,36 stream=True,37 )38 except Exception as e:39 log_exception(f"Unexpected error: {e}")404142if __name__ == "__main__":43 # The agent can read channels, users, messages, etc.44 asyncio.run(run_agent("Show me the latest message in the channel #general"))4546 # Use your real Slack name for this one to work!47 asyncio.run(48 run_agent("Send a message to <YOUR_NAME> saying 'Hello, I'm your Kern Agent!'")49 )