MCP คืออะไรและสำคัญอย่างไร
ทำความเข้าใจว่า Model Context Protocol กำหนดมาตรฐานอะไร แตกต่างจากการผสานการเรียกฟังก์ชันแบบเฉพาะกิจอย่างไร และเหตุใดจึงกำลังกลายเป็นภาษากลางสำหรับการเชื่อมต่อเครื่องมือปัญญาประดิษฐ์
MCP คืออะไรและสำคัญอย่างไร เป็นบทเรียน AI Engineering Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน AI Engineering Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส AI Engineering Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
The Tool Integration Problem
Every AI assistant today solves the same problem differently: how do you connect an LLM to your databases, APIs, files, and services? Without a standard, every integration is a custom one-off — OpenAI function calling works differently from Anthropic's tool use, which works differently from Gemini's. Developers rebuild the same adapters over and over.
What Is the Model Context Protocol?
Model Context Protocol (MCP) is an open standard created by Anthropic that defines a common interface for connecting LLMs to external data sources and tools. Think of it like USB for AI integrations — once a tool or data source implements the MCP server spec, any MCP-compatible AI client can use it without custom code. Announced in November 2024, it has rapidly gained adoption across the industry.
The Client-Server Architecture
MCP uses a client-server model: an AI application (the client) connects to one or more MCP servers. Each server exposes capabilities — tools the model can call, resources it can read, and prompt templates it can use. The client (such as Claude Desktop or a custom app) manages the connections and routes tool calls to the correct server.
- Client: Claude Desktop, VS Code extension, or your app
- Server: A process exposing tools via MCP — a database adapter, a file system, a web search service
MCP's Three Primitives
MCP servers expose three types of capabilities:
- Tools: Functions the model can call to take actions, similar to function calling. Example:
execute_query(sql). - Resources: Static or dynamic data the model can read — like files, database rows, or API responses. Example:
file:///config/settings.json. - Prompts: Reusable prompt templates the user can invoke with parameters. Example: a code review prompt that accepts a diff.
MCP vs. Direct Function Calling
With direct function calling, you define tools in your application code — tightly coupled to your LLM provider's API. With MCP, tools are defined in a separate server process that any client can connect to. Key differences:
- Portability: One MCP server works with Claude, custom apps, and future clients
- Reusability: Share MCP servers across teams and projects
- Separation of concerns: Tool servers can be maintained independently from the AI application
MCP Transport: stdio and HTTP/SSE
MCP servers communicate with clients over two transport mechanisms. stdio is used for local tools — the client spawns the server as a child process and communicates over stdin/stdout. This is simple and secure for developer tools. HTTP + Server-Sent Events (SSE) is used for remote servers accessible over a network, suitable for shared team tools or production deployments.
# Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json)
# Connecting to a local MCP server via stdio:
# {
# "mcpServers": {
# "my-database": {
# "command": "python",
# "args": ["/path/to/my_mcp_server.py"],
# "env": {
# "DATABASE_URL": "postgresql://localhost/mydb"
# }
# }
# }
# }The MCP Ecosystem
Since MCP's release, a growing ecosystem of pre-built servers has emerged. Anthropic maintains official servers for common integrations, and community servers cover hundreds of services. Rather than building custom tool integrations from scratch, you can drop in an existing MCP server.
- Official: GitHub, Google Drive, Slack, PostgreSQL, filesystem, web search
- Community: Jira, Notion, Stripe, Snowflake, MongoDB, and many more
- Custom: Build your own for proprietary internal tools
MCP in AI Development Workflows
MCP transforms AI coding assistants. With an MCP server connected to your codebase, Claude Desktop can read files, run tests, check git history, query databases, and browse documentation — all from a single chat window. This enables true agentic development where the AI understands and acts on your full development environment.
MCP SDK Overview
Anthropic provides SDKs for building MCP servers in Python and TypeScript. The Python SDK is mcp (install with pip install mcp). You define tools using decorators, resources using URI patterns, and the SDK handles the protocol negotiation, message serialization, and transport details for you.
# Install
# pip install mcp
# Minimal MCP server skeleton
from mcp.server import Server
from mcp.server.stdio import stdio_server
from mcp import types
app = Server('my-first-mcp-server')
@app.list_tools()
async def list_tools():
return [
types.Tool(
name='hello',
description='Returns a greeting message.',
inputSchema={
'type': 'object',
'properties': {
'name': {'type': 'string', 'description': 'Name to greet'}
},
'required': ['name']
}
)
]
@app.call_tool()
async def call_tool(name: str, arguments: dict):
if name == 'hello':
return [types.TextContent(type='text', text=f'Hello, {arguments["name"]}!')]
import asyncio
asyncio.run(stdio_server(app))Why MCP Matters for the Industry
MCP represents a shift toward standardization in AI tooling. Just as REST standardized web APIs and LSP standardized IDE language features, MCP is standardizing how AI models connect to tools. This benefits developers (build once, use everywhere), enterprises (audit and control one integration layer), and the ecosystem (shared, reusable tool libraries).
MCP Adoption and Future Direction
MCP adoption has grown rapidly since its launch. Major coding assistants (Cursor, Windsurf, VS Code Copilot), enterprise AI platforms, and cloud providers have announced MCP support. The protocol continues to evolve with proposals for authentication, sampling, and streaming improvements. Understanding MCP positions you to build interoperable AI integrations that work across the growing ecosystem.
Quick Check
Test your understanding of what MCP is and why it matters.
Lesson Recap
In this lesson you learned: MCP is an open standard that defines a universal interface for connecting LLMs to external tools and data sources, MCP servers expose three primitives: tools, resources, and prompts, and the MCP ecosystem provides pre-built servers for common services so you don't start from scratch. Next up we build our first MCP server in Python and connect it to Claude Desktop.
คำถามที่พบบ่อย
บทเรียน “MCP คืออะไรและสำคัญอย่างไร” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “MCP คืออะไรและสำคัญอย่างไร” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส AI Engineering Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส AI Engineering Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “MCP คืออะไรและสำคัญอย่างไร”
ทำความเข้าใจว่า Model Context Protocol กำหนดมาตรฐานอะไร แตกต่างจากการผสานการเรียกฟังก์ชันแบบเฉพาะกิจอย่างไร และเหตุใดจึงกำลังกลายเป็นภาษากลางสำหรับการเชื่อมต่อเครื่องมือปัญญาประดิษฐ์ คุณปฏิบัติ AI Engineering Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน AI Engineering Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน AI Engineering Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน
บทเรียน “MCP คืออะไรและสำคัญอย่างไร” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน AI Engineering Academy นี้ได้ไหม
ได้ บทเรียน AI Engineering Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- MCP คืออะไรและสำคัญอย่างไร
- การสร้างเซิร์ฟเวอร์ MCP แรกของคุณ
- การเปิดให้เข้าถึงทรัพยากรฐานข้อมูลผ่าน MCP
- ความปลอดภัยและการยืนยันตัวตนของ MCP