2.1 — What is MCP? — Model Context Protocol Explained Simply
What is MCP?
Model Context Protocol (MCP) is Anthropic's open standard for extending AI capabilities. Think of MCP as plugins for Claude. Instead of Claude being a closed system, MCP lets you build custom tools, data sources, and integrations that Claude can access. This lesson teaches MCP fundamentals and its power for Pakistani builders.
MCP in Plain English
Claude alone can: Read text, understand code, write prose, solve math. That's useful but limited.
Claude + MCP can: Read your SQL database in real-time, fetch data from external APIs, control smart devices, analyze files from cloud storage, all while Claude reasons about the results.
Example: You ask Claude "What was our revenue last month?" Claude (via MCP) queries your database, processes the data, returns answer with analysis. All in real-time.
MCP Architecture:
Your Computer/Server
└── MCP Host (Claude Code, IDE)
└── MCP Servers (your custom tools)
├── Database Server (reads your PostgreSQL)
├── API Server (calls external APIs)
├── File Server (reads Google Drive, Dropbox)
└── Custom Server (your proprietary logic)
Claude communicates with MCP servers. Each server provides "tools" (functions Claude can call). Example tools:
read_database: SELECT * FROM users WHERE date > '2026-01-01'fetch_weather: Get current temperature in Karachisend_email: Send email to customeranalyze_image: Parse invoice image for amounts
Why MCP Matters in 2026
Before MCP: Integrations were hacky. You'd write SDK wrappers, manage API keys, handle timeouts. Complex and fragile.
After MCP: Build once, reuse everywhere. One MCP server for your database, use it in Claude Code, in your web app, in your mobile app. Consistent interface.
For Pakistani builders: MCP enables local-first development. Build MCP server that talks to Zameen.pk API, JazzCash payment system, or NADRA database. Then use Claude to analyze data with AI intelligence. Example: "Analyze which Karachi neighborhoods have highest property appreciation" → Claude queries Zameen.pk via MCP, runs analysis.
MCP Communication Protocol
MCP uses JSON-RPC (JSON Remote Procedure Call) over stdio (standard input/output). Simple:
Client sends:
{
"jsonrpc": "2.0",
"id": 1,
"method": "resources/read",
"params": {
"uri": "database://users"
}
}
Server responds:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"contents": [
{
"uri": "database://users",
"mimeType": "application/json",
"text": "[{\"id\": 1, \"name\": \"Ahmed\"}, {\"id\": 2, \"name\": \"Fatima\"}]"
}
]
}
}
Don't memorize this. Tools abstract it away. You just call tools; the protocol is hidden.
MCP Capabilities
Every MCP server exposes capabilities (what it can do):
(1) Resources: Data sources Claude can read (databases, APIs, files)
- Example:
database://sales-2026(current year sales data) - Example:
api://weather(live weather data)
(2) Tools: Functions Claude can execute
- Example:
query_database(sql)- runs SQL query - Example:
send_sms(phone, message)- sends SMS via Jazz/Zong - Example:
create_invoice(items, customer)- generates invoice
(3) Prompts: Pre-built templates Claude can use
- Example:
analyze-financial-statements(template for analyzing business financials) - Example:
write-cold-email(template for outreach)
(4) Sampling: Let Claude sample data (useful for training/analysis)
- Example:
sample_database(table, limit)- get random 100 rows from table
MCP in Pakistani Context
Example: Pakistani e-commerce platform (Daraz competitor) uses MCP:
MCP Server 1: Inventory System
- Resources:
inventory://products,inventory://warehouse-karachi,inventory://warehouse-lahore - Tools:
check_stock(product_id, city),reorder_inventory(product_id, quantity),get_stockouts()
MCP Server 2: Customer Data
- Resources:
crm://customers,crm://orders,crm://returns - Tools:
fetch_customer(id),get_purchase_history(customer_id),identify_vip_customers(revenue_threshold)
MCP Server 3: Payment System
- Resources:
payments://transactions,payments://refunds - Tools:
process_payment(customer, amount, method),get_payment_status(transaction_id),refund(transaction_id)
Claude can now understand your business end-to-end:
- "Show me customers who bought but never left a review, then draft personalized thank you emails"
- Claude: Queries CRM → identifies customers → drafts emails via MCP tool
MCP Standards & Best Practices
Naming Convention: Use snake_case for tools and resources. query_database not queryDatabase.
Error Handling: Every MCP server must handle errors gracefully.
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32603,
"message": "Database connection failed",
"data": { "retry_in": 5 }
}
}
Rate Limiting: Protect your MCP servers (especially if calling paid APIs). Implement rate limiting.
Authentication: Secure your MCP servers. Use API keys or OAuth. Don't expose sensitive data.
Testing: Test your MCP server standalone before deploying.
Practice Lab
Task 1: Understand MCP Architecture — Draw a diagram of how MCP works: (1) Claude Code (client), (2) MCP Host, (3) Your MCP servers, (4) External systems (database, APIs). Label each component and describe its role.
Task 2: Plan Custom MCP Server — Design an MCP server for your niche. List: (1) Name, (2) Resources (3-5), (3) Tools (5-10), (4) Use cases. Example: "Restaurant MCP" with resources menu://items, orders://today, tools check_ingredient_stock(), generate_meal_recommendations().
Conclusion
MCP is the future of AI integration. Instead of hacking API calls into your code, you define a clean interface (MCP server), and Claude understands it instantly.
Master MCP, and you can build AI systems that integrate with any Pakistani business system: Zameen.pk property data, JazzCash payments, WhatsApp via WATI, SMS via Jazz/Zong. All unified under Claude's intelligence.
Lesson Summary
What is MCP Quiz
4 questions to test your understanding. Score 60% or higher to pass.