CTCaliberTek
Course: AI Agents: End to End · Lesson 6 of 7Log in to track your progress and earn a certificate when you finish the course.
AI & Machine Learning

Model Context Protocol (MCP) Basics: Connecting Agents to Tools

Published October 13, 2026·Updated October 29, 2026·8 min read
Like SaveLog in to like, save, and track progress.

Introduction

Every tool normally needs custom glue code for each AI application. The Model Context Protocol (MCP) is an open standard that lets a tool provider expose capabilities once and have any compatible AI application use them. This lesson explains the idea, builds a small server, and covers the security points you must not skip.

Prerequisites

  • Function calling lesson
  • Python 3.10 or newer

Step-by-Step Guide

Step 1: Understand the architecture

An MCP server exposes tools (actions the model can request), resources (data it can read), and prompts (reusable templates). An MCP client inside an AI application connects to servers and passes their tools to the model. Servers can run locally and talk over standard input and output, or run remotely over HTTP.

Step 2: Install the Python SDK

The official Python SDK includes a high-level helper called FastMCP for building servers quickly.

pip install "mcp[cli]"

Step 3: Build a small server

Decorate a typed function with the tool decorator. The function's name, type hints, and docstring become the tool's name, schema, and description, so write the docstring for the model as the reader.

# server.py
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("demo")


@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two integers and return the sum."""
    return a + b


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

Step 4: Connect an application to a server

Many AI applications can be configured to launch or connect to MCP servers. Some LLM APIs can also connect directly to remote MCP servers. With the Claude API, this beta connector needs both the server definition and a matching toolset entry. Check current documentation, since this feature is in beta.

import anthropic

client = anthropic.Anthropic()

response = client.beta.messages.create(
    model="claude-opus-5-5",
    max_tokens=16000,
    betas=["mcp-client-2025-11-20"],
    mcp_servers=[{"type": "url", "url": "https://example.com/mcp", "name": "docs"}],
    tools=[{"type": "mcp_toolset", "mcp_server_name": "docs"}],
    messages=[{"role": "user", "content": "Search the docs for the refund policy."}],
)

Step 5: Treat MCP servers as untrusted code and data

Only connect to servers you trust. A server runs code with the access you give it, and its tool descriptions and results are text that can try to manipulate the model. Grant minimum permissions, review what each tool can do, require approval for sensitive actions, and keep secrets out of server configurations you do not control.

FAQs

How is MCP different from regular function calling?
Function calling is how a model requests a tool within one API. MCP standardizes how tools are packaged and discovered so the same server works with many applications without custom integration each time.
Do I need MCP to build an agent?
No. Direct tool definitions are simpler for a single application. MCP pays off when you want to reuse tools across applications or use servers others have built.

Summary

MCP standardizes how tools reach AI applications. Expose tools with a small server, connect clients to it, and treat every server as a trust boundary with minimal permissions and human approval for risky actions.

Related tutorials

Comments

Log in or create a free account to join the discussion.

  • No comments yet. Be the first to comment.