Agent + Weather MCP integration
This integration gives an Agent real-time weather ability through a shared Weather MCP server. The agent calls the MCP tool the same way it calls any other tool, while the weather logic stays isolated and versioned.
When to use it
Use this pattern when you want a model to answer with current facts from a controlled tool instead of free browsing. The MCP contract is small and explicit, which makes it easy to verify and easy to roll back.
The pieces
- MCP server — hosts the weather tools.
- Weather tool — returns current conditions for a city.
- Agent — calls the tool and turns the result into a user-facing answer.
Step 1: Publish the weather tool
- platformctl
- curl
- Console
platformctl mcp create weather-tools
platformctl mcp tools set weather-tools get_forecast \
--handler @get_forecast.py \
--description "Current weather for a city"
curl -s -X POST "$CAI_API/v1/projects/$PROJ/mcpservers" \
-H "Authorization: Bearer ***" \
-H 'Content-Type: application/json' \
-d '{"name":"weather-tools","expose":""}'
jq -n --rawfile handler get_forecast.py \
'{handler: $handler, description: "Current weather for a city"}' |
curl -s -X PUT "$CAI_API/v1/projects/$PROJ/mcpservers/weather-tools/tools/get_forecast" \
-H "Authorization: Bearer ***" \
-H 'Content-Type: application/json' \
-d @-
- Open Compute → MCP servers and Deploy server, named
weather-tools. - Publish tool, named
get_forecast, with your handler. - The tool appears under Tools once the build deploys.
Step 2: Give the agent a tool contract
The agent should see only the tool call shape. Keep it simple:
- one argument,
city: string - one result object
- a short error when the city is unknown
That keeps the model focused on the decision instead of forcing it to parse arbitrary prose.
Step 3: Attach the tool to the agent
How the agent attaches depends on the framework. The important part is that the MCP server becomes a first-class tool in the agent's toolset.
- ADK
- LangGraph
- CrewAI
from google.adk.agents import Agent
from crusoe_adk.foundry import foundry_model
from crusoe_adk.mcp import mcp_toolsets
from crusoe_adk.tools import run_python
root_agent = Agent(
name="weather_agent",
model=foundry_model(),
instruction=("Use tools when asked for current weather.\n\n"
"Prefer MCP tools over guessing."),
tools=[run_python, *mcp_toolsets()],
)
import asyncio
from langgraph.prebuilt import create_react_agent
import crusoe_langchain as crusoe
_tools = asyncio.run(crusoe.mcp_tools())
graph = create_react_agent(
crusoe.foundry_model(),
tools=[crusoe.run_python, *_tools],
prompt=("Use tools when asked for current weather.\n\n"
"Prefer MCP tools over guessing."),
)
from crewai import Agent, Crew, Process, Task
import crusoe_crewai as crusoe
assistant = Agent(
role="Weather Assistant",
goal="Answer current weather questions using the attached tools.",
backstory="A concise assistant using a weather MCP server.",
llm=crusoe.foundry_model(),
tools=[crusoe.RunPython()] + crusoe.mcp_tools(),
verbose=False,
)
crew = Crew(
agents=[assistant],
tasks=[],
process=Process.sequential,
)
mcp_toolsets() and mcp_tools() attach every Ready MCP server the project has. Pass names="weather-tools" — a string, or a list of names — when the agent should not see every tool in the project, or must not have its toolset widened the day somebody else deploys a server. A name that is not attached raises crusoe_core.UnknownMCPServer listing what is attached, rather than quietly attaching nothing.
The platform bakes the project's Ready MCP servers into the agent's revision at deploy time, as the locked MCP_SERVERS variable — you cannot set it by hand afterwards, and a server that is not Ready is skipped. Publishing a tool answers 202 and starts a build; the server is not Ready until that build deploys.
So publish the tool, wait for Ready (platformctl mcp get weather-tools), then deploy — or redeploy — the agent. An agent deployed first gets an empty toolset and answers from memory, which looks exactly like the prompting failure Step 4 tells you to watch for.
Step 4: Test the flow
Ask for the weather and then verify two things:
- the model used the tool rather than inventing a fact, and
- the answer matched the tool's response shape.
A good acceptance test is to ask for a city you know is in the tool's table. The response should be stable and exact. A city outside the table should produce the same honest error your MCP tool returns.
Common mistakes
- Forgetting that the MCP tool is versioned. The agent sees the currently deployed version; rollback returns to an older version, not an older source.
- Mixing manual HTTP calls with MCP calls. The MCP protocol is the contract — agents and clients should use the standard tool call flow, not custom endpoints.
- Letting the agent do the lookup in prose. The point of this pattern is that the model gets structured tool results, not a long web scrape.