MCP Fundamentals
Model Context Protocol (MCP)
Large Language Models (LLMs) like Claude, ChatGPT, and other AI assistants are powerful, but they normally operate in isolation. They cannot directly access your computer, read files, run programs, or query databases.
The Model Context Protocol (MCP) is a standard that allows language models to safely interact with external tools and data sources.
Instead of executing code directly, the language model communicates with an MCP server, which exposes specific capabilities that the model can use.
Learn more: Model Context Protocol Documentation
Mental Model: How MCP Actually Works
A helpful way to think about MCP is that the language model is a decision maker and the MCP server is a toolbox.
User asks question
↓
Claude decides which tool to use
↓
Claude calls the MCP server
↓
Your Python function runs
↓
The result is returned to Claude
↓
Claude explains the result to the user
Important: The language model does not run your code directly. It decides which tool should be executed. The MCP server runs the code and returns the result.
MCP Architecture
The interaction between the user, the language model, and your MCP server looks like this:
User Prompt
↓
Language Model (Claude)
↓
MCP Client
↓
MCP Server
↓
Tools / Data Sources
The language model analyzes the prompt and determines whether a tool should be used.
If a tool is needed:
1. The model selects a tool 2. The MCP client sends the request 3. The MCP server runs the function 4. The result is returned to the model 5. The model formats the final response
MCP Building Blocks
MCP servers provide three types of capabilities.
Tools
Tools are executable functions that perform actions or retrieve data.
Examples include:
- querying a database
- reading files
- performing calculations
- calling APIs
- searching datasets
Example tool:
get_weather(city="St. Louis")
The MCP server runs the function and returns the result.
Resources
Resources are the data sources your MCP tools use.
Examples include:
- files
- documents
- databases
- logs
- datasets
For example, a tool might read a dataset stored in a file.
Prompts
Prompts are the instructions given by the user.
Example:
Show the top hitters on the 1940 Cardinals.
The model interprets the prompt and determines if a tool should be used.
The user never runs the tool directly.
Example Workflow
Suppose the user asks:
Show the top hitters on the 1940 Cardinals.
The system behaves like this:
1. Claude reads the prompt
2. Claude decides the get_top_players tool is needed
3. Claude calls the MCP server
4. The server runs the Python function
5. The results are returned to Claude
Why MCP Matters
Without MCP, language models can only generate text.
With MCP, models can:
- access real data
- run programs
- query databases
- analyze datasets
- automate workflows
This transforms AI systems from chatbots into agents.
MCP in This Course
In this module, you will build a simple MCP server using Python.
Your server will expose tools that allow Claude Desktop to analyze historical St. Louis Cardinals batting statistics.
Claude will automatically call your tools when needed.