Serve your tools from an MCP server

DevOps, Hands On30 minutesFreeSteps checked 23 November 2026By Cloud Hands On

In this task you'll share your agent's tools through an MCP server that any MCP client can use.

The Model Context Protocol (MCP) is an open standard for offering tools (and files and prompts) to AI apps. You write an MCP server once; any MCP client (an IDE, a chat app, your own agent) can list its tools and call them. The local kind runs over stdio: the client starts the server as a program and talks to it through standard input and output.

With the Python SDK you write ordinary functions and mark them with @server.tool(); the SDK builds each tool's schema from the type hints and its description from the docstring. Tool annotations such as read_only_hint tell clients which tools only read, so a client can ask before running anything else. Version 2 of the package names the server class MCPServer (older guides say FastMCP).

Example. Ironbridge Payments has three teams building AI helpers. Instead of each writing its own 'read the logs' code, the platform team publishes one read-only MCP server for logs and metrics, and every helper connects to it.

Before you start

You need: Python 3.10 or newer (on Windows, use py where the steps say python). No AI account: the practice model runs on your computer. The official MCP Python package (pip install "mcp>=2"), best in a virtual environment. Time: 30 minutes.

Where to look

  1. agents folder
  2. ops_server.py
  3. mcp_client.py

Steps

  1. In the agents folder, make a virtual environment and install the SDK: python -m venv .venv, activate it, then pip install "mcp>=2".
  2. Save ops_server.py and mcp_client.py from Commands.The server reuses the Example services from practice_model.py.
  3. Run python mcp_client.py. It starts the server, lists two tools marked read-only with their schemas, and calls get_status for shop-api.
  4. Add a third tool to the server (for example a list of services), run the client again and see it listed with no change to the client.That's the point of a standard: new tools appear without new client code.

Commands

python -m venv .venv
# Windows: .venv\Scripts\activate    macOS or Linux: source .venv/bin/activate
pip install "mcp>=2"

# ops_server.py
# ops_server.py: the same ops tools, served over MCP so any MCP client (an IDE, a chat app, your agent) can use them.
from mcp.server import MCPServer
from mcp.types import ToolAnnotations
from practice_model import SERVICES

server = MCPServer("ops-tools", instructions="Read-only health and log tools for the Example shop services.")

@server.tool(annotations=ToolAnnotations(read_only_hint=True))
def get_status(service: str) -> str:
    """Get the health status, latency and ready pods of a service."""
    return SERVICES[service]["status"] if service in SERVICES else f"unknown service {service}"

@server.tool(annotations=ToolAnnotations(read_only_hint=True))
def read_logs(service: str) -> str:
    """Read the latest log lines of a service to find errors and warnings."""
    return "\n".join(SERVICES[service]["logs"]) if service in SERVICES else f"unknown service {service}"

if __name__ == "__main__":
    server.run()   # stdio: the client starts this file and talks to it over standard input and output

# mcp_client.py
# mcp_client.py: start ops_server.py, list its tools and call one, the way an agent host does.
import asyncio, sys
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

async def main():
    params = StdioServerParameters(command=sys.executable, args=["ops_server.py"])
    async with stdio_client(params) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()
            for t in (await session.list_tools()).tools:
                print(f"tool: {t.name}  read-only: {t.annotations.read_only_hint if t.annotations else None}  - {t.description}")
                print(f"      input: {t.input_schema['properties']}")
            result = await session.call_tool("get_status", {"service": "shop-api"})
            print("get_status(shop-api) ->", result.content[0].text)

asyncio.run(main())

python mcp_client.py

Watch out for

Cost
Free.
Security
Treat an MCP server like any other code you install: run servers you trust, give them only the access they need, and prefer read-only tools. A server can describe its tools in ways meant to steer the model.
Common mistakes
Following an old guide that imports FastMCP from mcp.server.fastmcp (version 1), and printing to standard output from a stdio server, which corrupts the protocol messages.

Clean up

Deactivate the virtual environment with deactivate. Delete the .venv folder when you've finished the track.

Words to know

MCP
Model Context Protocol: a standard way to offer tools and data to AI apps.
MCP server
A program that offers tools to MCP clients.
stdio transport
The client starts the server and they talk through standard input and output.
Tool annotation
A hint about a tool's behaviour, such as read-only.

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going