Model Context Protocol (MCP) Service¶
In this tutorial, you'll build a Model Context Protocol (MCP) server using WSO2 Integrator: BI. The MCP server exposes tools that AI assistants can discover and invoke to interact with external data sources, services, and workflows.
By the end of this tutorial, you'll have created an MCP service with weather-related tools that allow AI assistants to retrieve current weather data for different locations.
Note
The Model Context Protocol (MCP) is an open standard for connecting AI applications to external data sources, tools, and workflows. MCP servers expose capabilities that AI assistants can discover and use dynamically, enabling seamless integration between AI models and external systems.
Prerequisites¶
Before you begin, ensure you have WSO2 Integrator: BI installed and configured in your development environment.
What is an MCP Service?
An MCP service acts as a bridge between AI assistants and external systems. It exposes a set of tools—functions that AI assistants can call to perform specific tasks like fetching data, executing operations, or interacting with APIs. The AI assistant discovers available tools through the MCP protocol and invokes them as needed during conversations.
Step 1: Create a new integration project¶
- Click on the BI icon in the sidebar.
- Click on the Create New Integration button.
- Enter the project name as
mcp_weather_service. - Select a directory location by clicking on the Select Path button.
-
Click Create New Integration to generate the project.
Step 2: Create an MCP service¶
In WSO2 Integrator: BI, an MCP service is an artifact that exposes tools following the Model Context Protocol standard. AI assistants can connect to this service to discover and invoke the tools you define.
- In the design screen, click on + Add Artifact.
- Select MCP Service under the AI Integration artifact category.
- Enter the service name as
Weather MCP. - Leave the other fields at their default values.
-
Click Create to open the MCP service editor.
Step 3: Define tools for the MCP service¶
Tools are the core building blocks of an MCP service. Each tool represents a specific capability that AI assistants can invoke.
- Under the Tools section of the MCP service, click on + Add Tool.
- Configure the tool with the following details:
- Tool Name:
getCurrentWeather - Description:
Retrieve current weather data for a specified location.
- Tool Name:
- Under Input Parameters, add a parameter:
- Name:
location - Type:
string - Description:
The location for which to retrieve the current weather.
- Name:
- Set the Return Type to
string. -
Click Save to add the tool.
Note
Tool descriptions are important—they help AI assistants understand when and how to use each tool. Write clear, concise descriptions that explain what the tool does and what input it expects.
Step 4: Implement tool logic¶
Now you'll implement the logic that executes when the tool is invoked. For this example, we'll use conditional logic to simulate weather data retrieval.
- Click on the getCurrentWeather tool to open its implementation flow diagram.
- Hover over the flow line and click the + icon to open the side panel.
- Select If from the Control section.
- In the condition field, enter the following expression:
location == "New York" - Click Add Else Block to handle other locations.
- Click Save to add the conditional block.
- In the If block, hover over the flow line and click the + icon.
- Select Return from the Control section.
- Set the return value to
"Sunny, 72°F". - Click Save.
- In the Else block, hover over the flow line and click the + icon.
- Select Return from the Control section.
- Set the return value to
"Weather data not available for this location.". -
Click Save.
Note
This example uses simple conditional logic for demonstration purposes. In a real-world scenario, you would integrate with actual weather APIs using HTTP connectors or other data sources available in WSO2 Integrator: BI.
Step 5: Add more tools (optional)¶
You can extend your MCP service with additional tools to provide more capabilities.
- Click on
mcp:Servicein the left panel to return to the MCP service overview. -
Click on + Tool and repeat the process from Step 3 to define and implement more tools as needed.
Step 6: Test the MCP service¶
Once you have defined and implemented your tools, you can test the MCP service to ensure it works correctly.
- In the left panel, click on
mcp:Serviceto return to the MCP service overview. - Click on the Try It button in the top-right corner.
- When prompted, install the MCP Inspector extension by clicking Install.
- Once the installation is complete, click Try It again to open the MCP Inspector.
- In the MCP Inspector:
- Click Connect to establish a connection with your MCP service.
- Click List Tools to view all tools exposed by the service.
Connecting AI Assistants
Once your MCP service is running, AI assistants can connect to it using the MCP protocol. The service URL and available tools will be discoverable through the standard MCP handshake process.
What's Next?¶
Now that you've created a basic MCP service, you can:
- Add more sophisticated tool implementations using HTTP connectors to integrate with real APIs.
- Define additional tools for different use cases.
- Deploy your MCP service to a production environment for use with AI assistants.




