Skip to main content

Tutorial: Agent + Weather MCP

This tutorial builds a working weather assistant from two pieces you have already met: an MCP server with a weather tool, and an Agent that knows how to call it. The point is not the weather itself — it is the pattern. The same shape works for any controlled tool you want an agent to use safely.

What you are building

  • weather-tools — an MCP server that exposes a weather lookup tool.
  • weather-agent — the agent that calls the tool and answers the user.

By the end, you can ask the agent for a city's conditions and get the answer through MCP instead of a guess.

Before you begin

  • An account with project admin, or a project member working with your administrator.
  • platformctl, signed in.
  • The weather tool from Publish tools or the weather tutorial.

Step 1: Publish the weather tool

platformctl mcp create weather-tools
platformctl mcp tools set weather-tools get_forecast \
--handler @get_forecast.py \
--description "Current weather for a city"

Step 2: Confirm the server is ready

Read the server back until the response is ready: true and you have an endpoint URL.

platformctl mcp get weather-tools

Step 3: Call the tool directly once

Before wiring the agent, prove the tool works from curl. This gives you a baseline that is independent of the model.

curl -s -X POST "$MCP_URL" \
-H "Authorization: Bearer $MCP_BEARER" \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_forecast","arguments":{"city":"Reykjavik"}}}'

You should see a JSON-RPC result with the forecast object. If this fails, fix the MCP side first — the agent will only inherit that failure.

Step 4: Wire the agent to the MCP server

Write an agent that prefers the tool when the question is about weather. Keep the instruction narrow so the model chooses the tool quickly instead of reasoning around it.

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. "
"Prefer MCP tool results over guessing."),
tools=[run_python, *mcp_toolsets()],
)

Step 5: Ask the agent

Send the question and check two things:

  • the agent chose the MCP tool,
  • the answer reflects the tool's response rather than an invented forecast.

What success looks like

A working run usually looks like this:

  1. tool call selected,
  2. get_forecast invoked,
  3. a concise answer that matches the tool result.

Common failures

  • Tool not ready. The server is still building or deploying.
  • Wrong secret handling. The weather tool's credential key was declared but the project secret value was never set.
  • Model guessing instead of tool use. The instruction needs to be narrower, or the tool set is not attached.

Next steps

Go deeper

These advanced guides pick up where the quickstarts stop, each exercising a different slice of the platform:

GuideFramework / language
Multi-step research agentLangGraph
Editorial pipeline with a crewCrewAI
Support agent over your own docsADK
Document ingestion pipelinePython
Webhook fan-out, exactly onceNode.js
Scheduled reconciliation jobGo
Object-store ETL with move-after-readRuby