This example demonstrates how to use MCP tools in a ReAct agent.
- Install
coagent(see Installation). - Start a NATS server (see Distributed).
Set the environment variables for your model:
export MODEL_ID="your-model-id"
export MODEL_BASE_URL="your-base-url"
export MODEL_API_KEY="your-api-key"Run the MCP server:
python examples/react-mcp/server.pyRun the agent:
python examples/react-mcp/agent.pyI'll check the weather in Beijing for you right away.
[tool#call_hs9xiswsunbcynv946n43z46 call: get_weather]
[tool#call_hs9xiswsunbcynv946n43z46 progress: Getting weather for Beijing]
[tool#call_hs9xiswsunbcynv946n43z46 output: The weather in Beijing is sunny.]
The weather in Beijing is sunny today! It looks like a beautiful day there.