AI Engineering Tutorial · Tools and Agents · Lesson 14 of 25

MCP in Five Minutes

The Model Context Protocol lets any AI app discover and call tools from servers you write once.

Create a free account to save this page, take notes and track your progress. Sign in

The idea

Without a standard, every AI app writes its own integration for every system. The Model Context Protocol (MCP) standardises this: you wrap a system once in an MCP server that exposes tools (actions), resources (data) and prompts; any MCP-capable app (a host with an MCP client) discovers and uses them. Messages are JSON-RPC; local servers usually use stdio, remote servers Streamable HTTP.

A server with the official Python SDK:

from mcp.server import MCPServer

mcp = MCPServer("Weather")

@mcp.tool()
def forecast(city: str, days: int = 3) -> list[dict]:
    '''Daily forecast for a city.'''
    return weather_api.daily(city, days)

if __name__ == "__main__":
    mcp.run()            # stdio; mcp.run(transport="streamable-http") for remote use
The MCP message flowTry it yourself
import json
# the three messages a client sends to start using a server (simplified)
flow = [
    {"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-11-25", "clientInfo": {"name": "my-app"}}},
    {"jsonrpc": "2.0", "id": 2, "method": "tools/list"},
    {"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "forecast", "arguments": {"city": "Oslo"}}},
]
for msg in flow:
    print(json.dumps(msg))

Output

{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-11-25", "clientInfo": {"name": "my-app"}}}
{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}
{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "forecast", "arguments": {"city": "Oslo"}}}

Learn more at modelcontextprotocol.io.

Test yourself

What does an MCP server provide?

  1. A new language model
  2. Tools, resources and prompts that any MCP-capable app can discover and use
  3. A vector database
  4. A user interface
Show answer

Answer: Tools, resources and prompts that any MCP-capable app can discover and use

MCP standardises how apps connect to tools and data.

Was this page helpful?