Integrate MCP Servers with WatsonX Orchestrate in 10 Minutes

Overview

The Model Context Protocol (MCP) is an open standard that enables AI agents to securely connect to data sources and tools. In this quick tutorial, you’ll learn how to create a simple MCP server using FastMCP and integrate it with WatsonX Orchestrate to build an intelligent hiking advisor agent.

Our hiking advisor will use two tools that work together:

  1. get_weather – Retrieves weather conditions and temperature for any location
  2. can_go_hiking – Analyzes the temperature to determine if conditions are suitable for hiking

The agent will intelligently chain these tools together to provide personalized hiking recommendations.

Project Structure

First, let’s set up the folder structure. Create the following directories and files:

Simple-MCP-Server/
├── agents/
│   └── hiking_advisor_agent.yaml
└── tools/
    ├── requirements.txt
    └── hiking_mcp_server.py

Create the requirements.txt

In the tools/ folder, create a requirements.txt file:

fastmcp

Now let’s create each file step by step.

Step 1: Create the MCP Server

In the tools/ folder, create a file called hiking_mcp_server.py:

Note: For simplicity, the `get_weather` tool generates random weather data to simulate real-world scenarios. In production, you would replace this with actual weather API calls.

from fastmcp import FastMCP
import random

# Instantiate an MCP server
mcp = FastMCP("Hiking Advisor Tools")

@mcp.tool()
def get_weather(location: str) -> str:
    """
    Call this method to get the weather in fahrenheit for any location.
    
    Args:
        location: The location to get weather for
        
    Returns:
        str: A sentence describing the weather condition and temperature
    """
    primary_conditions = ["Sunny", "Cloudy", "Rainy", "Stormy", "Snowy", "Windy", "Foggy"]
    secondary_conditions = ["Foggy", "Windy", "Humid", "Chilly", "Misty", "Overcast", "Breezy"]

    weather1 = random.choice(primary_conditions)
    weather2 = random.choice(secondary_conditions) if random.random() > 0.5 else None

    if weather1 == "Snowy":
        temperature = random.randint(10, 32)
    elif weather1 in ["Rainy", "Cloudy", "Foggy"]:
        temperature = random.randint(40, 65)
    elif weather1 == "Windy":
        temperature = random.randint(50, 75)
    else:
        temperature = random.randint(60, 100)

    if weather2:
        return f"It is {weather1.lower()} and {weather2.lower()} with temperature as {temperature}°F."
    else:
        return f"It is {weather1.lower()} with temperature as {temperature}°F."

@mcp.tool()
def can_go_hiking(temperature: int) -> str:
    """
    Call this method to decide if it's a good idea to go hiking based on the given temperature.
    
    Args:
        temperature: The current temperature in Fahrenheit
        
    Returns:
        str: A message indicating whether it's suitable for hiking
    """
    if temperature < 35:
        return "It's too cold for hiking. Better stay indoors!"
    elif temperature < 50:
        return "It's a bit chilly for hiking. Wear warm layers if you go!"
    elif temperature > 95:
        return "It's too hot for hiking. Stay hydrated and avoid midday sun!"
    else:
        return "The weather is great for hiking. Enjoy your adventure!"

if __name__ == "__main__":
    mcp.run()

Step 2: Create the Agent Configuration

Next, create the agent YAML file that will use these MCP tools. In the agents/ folder, create hiking_advisor_agent.yaml:

spec_version: v1
style: react
name: mcp_hiking_advisor_agent
display_name: Hiking Advisor Agent
llm: watsonx/meta-llama/llama-3-3-70b-instruct
description: >
  You are a Hiking Advisor agent. You help users decide if it's a good time to go hiking based on the weather conditions at their location.
instructions: >
  To help users decide if they should go hiking, follow these steps:
  
  1. First, call the get_weather tool with the location the user provides to get the current weather conditions and temperature.
  2. Extract the temperature value from the weather response.
  3. Then, call the can_go_hiking tool with the temperature to get a recommendation about hiking.
  4. Provide a friendly response that includes the weather conditions and the hiking recommendation.
  
  When user greets with any greeting like Hi or Hello, introduce yourself as a Hiking Advisor agent who can help determine if it's a good time to go hiking based on weather conditions.
  
  Example questions users might ask:
  - Is it a good time to go hiking in San Francisco?
  - Should I go hiking today in Denver?
  - What are the hiking conditions in Seattle?
  
  Always be friendly and provide clear, helpful advice. If the conditions are not ideal, suggest what the user should do instead or what to wear if they still want to go.
tools:
  - mcp-hiking-tools:get_weather
  - mcp-hiking-tools:can_go_hiking

The agent YAML file provides the instructions and behavior guidelines for our agent, along with access to the MCP tools. These instructions act as a guide, telling the agent when to call each tool and how to respond to user queries.

Note: how the tools are referenced with the namespace mcp-hiking-tools that we’ll create in the next step.

Step 3: Import Tools and Agent to WatsonX Orchestrate

Now let’s import the MCP server tools and agent into WatsonX Orchestrate. Run these commands from the Simple-MCP-Server/ directory.

Import the MCP Tools

orchestrate toolkits import \
--kind mcp \
--name mcp-hiking-tools \
--description "Tools helps in hiking decision" \
--package-root tools/ \
--language python \
--command "python hiking_mcp_server.py" \
-r tools/requirements.txt

This command registers your MCP server as a toolkit in WatsonX Orchestrate, making both tools available under the mcp-hiking-tools namespace.

Note: Here we are importing all the tools to the orchestrate. One can use –tool parameter to import only specific selected tools.

Import the Agent

orchestrate agents import -f agents/hiking_advisor_agent.yaml

Step 4: Test Your Agent

Once you’ve successfully run the import commands, navigate to the WatsonX Orchestrate UI to interact with your hiking advisor agent.

That’s it! Your MCP-powered hiking advisor agent is now ready to use in WatsonX Orchestrate. Try asking it questions like:

  • “Is it a good time to go hiking in San Francisco?”
  • “Should I go hiking in Denver today?”
  • “What are the hiking conditions in Seattle?”

The agent will automatically call get_weather first, extract the temperature, then call can_go_hiking to provide a personalized recommendation.

What Makes This Powerful?

This example showcases three key benefits of MCP integration with WatsonX Orchestrate. First, it demonstrates a multi-tool workflow where the agent intelligently chains tools together. Second, the seamless integration requires just one command—no complex configuration, adapters, or manual registration. The MCP protocol handles all communication automatically. Finally, it’s highly extensible—add new tools to your MCP server and re-import to instantly make them available to your agents.

Conclusion

In just 10 minutes, you’ve built a functional MCP-powered agent and experienced the seamless integration that WatsonX Orchestrate provides. No REST API wrappers, no authentication middleware, no complex configuration—just one command to bridge your tools with the entire Orchestrate ecosystem. This same pattern scales to real-world applications across any industry or use case.

Ready to build your own MCP-powered agents? Start with a simple use case, create your tools using FastMCP, and let WatsonX Orchestrate handle the rest. For more information on MCP integration and advanced features, check out the WatsonX Orchestrate MCP Server documentation.

Comments

Leave a Reply

Discover more from AI Tech Byte

Subscribe now to keep reading and get access to the full archive.

Continue reading