ทำไม MCP server เปลี่ยนวิธีใช้ AI ตลอดไป
ปัญหาในปี 2024 ก่อน MCP
ตอนนั้นถ้าคุณอยากให้ ChatGPT/Claude/Gemini ทำงานจริง — ต้อง:
- เขียน wrapper API ของตัวเอง
- Function calling format ต่างกัน ระหว่าง provider — code redundant
- Plugin ของ ChatGPT มีแต่ทำงานได้ใน ChatGPT เท่านั้น (และ ปิดตัวไปแล้ว!)
- ไม่มี standard — ทุกบริษัทคิด protocol ของตัวเอง
ผลลัพธ์? Dev ใช้เวลามากในการ wrap APIs ของตัวเองครั้งแล้วครั้งเล่า
MCP คืออะไร?
Model Context Protocol = open standard ที่ Anthropic ออกในปี 2024 สำหรับให้ AI agent (Claude / Manus / GPT-4 / ฯลฯ) คุยกับ external tools
┌──────────┐ MCP ┌─────────────────┐
│ Claude │ ◀──────────────────▶ │ Your MCP Server │
│ /Manus │ stdio/SSE │ (Python/TS/Go) │
│ /GPT │ │ │
└──────────┘ └────────┬────────┘
│
▼
Railway / DB / Files /
APIs / Hardware / ฯลฯMCP แก้ปัญหายังไง:
| ก่อน MCP | หลัง MCP |
|---|---|
| Plugin per provider | Server เดียวใช้กับทุก AI |
| Function format ต่างกัน | JSON-RPC standard |
| Closed (proprietary) | Open spec, MIT license |
| Hard to test | Standalone server ที่ test ได้แยก |
| Vendor lock-in | ย้าย AI provider โดยไม่แก้ tool |
ตัวอย่างจริง: NirvaDeploy MCP
NirvaDeploy เป็น MCP server ตัวแรกๆ ที่ออกแบบมาเพื่อ Thai market — มี 16 tools ที่ AI agent เรียกใช้ผ่านบทสนทนาภาษาไทยได้:
@mcp.tool(
name="nirvadeploy_list_projects",
annotations={
"readOnlyHint": True,
"destructiveHint": False,
"idempotentHint": True,
"openWorldHint": True,
},
)
async def nirvadeploy_list_projects() -> str:
"""แสดงรายชื่อโปรเจกต์ NirvaDeploy ทั้งหมด"""
# ... call Railway GraphQL ...
return formatted_thai_outputUser คุยกับ Claude:
"ดูโปรเจกต์ใน NirvaDeploy ที"
Claude เห็น tool nirvadeploy_list_projects (จาก MCP) → เรียกใช้ → ได้ output ภาษาไทยกลับมา
3 concepts สำคัญ
1. Tools
Function ที่ AI agent เรียกได้. ทุก tool มี:
- Name (
nirvadeploy_list_projects) - Description (ภาษาไทยก็ได้)
- Input schema (Pydantic / JSON Schema)
- Return value (string ที่ AI อ่านได้)
2. Annotations
Metadata บอก AI ว่า tool นี้ "ทำอะไร":
readOnlyHint— อ่านอย่างเดียว? (AI เรียกได้อิสระ)destructiveHint— undo ได้ไหม? (AI ต้องขอ confirm จาก user)idempotentHint— เรียกซ้ำ = ผลเดิม? (AI retry ได้)openWorldHint— ขึ้นกับ external state? (AI ไม่ควร cache)
3. Transport
วิธีที่ AI client คุยกับ MCP server:
- stdio — local subprocess (Claude Desktop ใช้)
- SSE/HTTP — hosted, network-accessible (สำหรับ web deploy)
ทำไมต้องเป็น MCP (ไม่ใช่ plain REST API)?
Plain REST API:
- AI ต้องเขียน wrapper เพื่อ understand schema
- ไม่มี annotation hints → AI อาจเรียกซ้ำ หรือ destructive โดยไม่ confirm
- Provider-specific format → ทำใหม่กับทุก AI
MCP:
- AI agent ที่ support MCP เรียก tool ได้ทันที (Claude, Manus, GPT-4 turbo, Cursor)
- Annotation hints → AI ตัดสินใจถูก (confirm destructive, batch reads)
- Server ตัวเดียว → ทำงานกับทุก AI client
Use cases ที่ Thai dev เริ่มทำได้แล้ว
- Database admin via AI — "เพิ่มคอลัมน์ email_verified ใน users table"
- DevOps via AI — "deploy service api ใหม่" (← NirvaDeploy)
- CRM via AI — "ตอบ ticket ที่ค้าง > 24 ชม."
- E-commerce via AI — "ดู order ที่ pending payment ของวันนี้"
- Internal tools — สร้าง MCP server ภายในบริษัท ให้ AI เข้าถึงข้อมูล company
เริ่มยังไง?
A. ใช้ MCP server ที่มีอยู่
- NirvaDeploy (PaaS):
Nirvacore/nirvadeploy - GitHub:
modelcontextprotocol/servers(Slack, Google Drive, Postgres, ฯลฯ) - ดูรายการเต็มที่ mcp-marketplace.com
B. เขียนเอง (ง่ายมาก)
Python + FastMCP:
from mcp.server.fastmcp import FastMCP
from pydantic import BaseModel, Field, ConfigDict
mcp = FastMCP("my_app")
class CountInput(BaseModel):
model_config = ConfigDict(extra="forbid")
text: str = Field(..., min_length=1)
@mcp.tool(
name="count_words",
annotations={"readOnlyHint": True, "destructiveHint": False,
"idempotentHint": True, "openWorldHint": False},
)
async def count_words(params: CountInput) -> str:
return f"📊 มี {len(params.text.split())} คำ"
if __name__ == "__main__":
mcp.run()3 ขั้นตอน → MCP server พร้อมใช้
C. เชื่อมเข้า Claude Desktop
แก้ config:
{
"mcpServers": {
"my_app": {
"command": "python",
"args": ["/path/to/my_server.py"]
}
}
}Restart Claude → เห็น tool ใหม่ทันที
ทำไมต้อง NirvaDeploy สำหรับ Thai dev?
ถ้าคุณจะเขียน MCP server → คุณต้อง deploy ที่ไหนสักที่.
NirvaDeploy:
- PaaS ไทย ราคา ฿111/mo
- เชื่อม Claude ผ่าน MCP ของเราเอง
- Deploy MCP server ของคุณผ่าน Claude → ใช้ MCP เพื่อ deploy MCP! 🤯
อ่านต่อ
Subscribe Line OA `@nirvadeploy` รับ updates เกี่ยวกับ MCP + AI dev ในไทย
ชอบบทความนี้?
ลอง NirvaDeploy ฟรี
Free tier ตลอดชีพ · ไม่ต้องใส่บัตร · Sign in ด้วย Line/Google
เริ่มเลย →