Máy chủ MCP bên thứ ba

Giới thiệu về Model Context Protocol (MCP)

James Chapman

AI Curriculum Manager, DataCamp

Vì sao dùng máy chủ MCP bên thứ ba?

 

  • Tốc độ: truy cập hệ thống tệp và cơ sở dữ liệu mà không cần viết máy chủ

mcp-archive.png

Giới thiệu về Model Context Protocol (MCP)

Vì sao dùng máy chủ MCP bên thứ ba?

 

  • Tốc độ: truy cập hệ thống tệp và cơ sở dữ liệu mà không cần viết máy chủ
  • Bên khác duy trì: bạn tập trung vào client và ứng dụng
  • Tích hợp: có thể dùng chung và tái sử dụng mã client cho nhiều máy chủ MCP

snowflake-mcp.png

1 https://www.snowflake.com/en/developers/guides/getting-started-with-snowflake-mcp-server/
Giới thiệu về Model Context Protocol (MCP)

Lưu ý trước khi dùng máy chủ bên thứ ba

 

  • Tin cậy: máy chủ chạy mã và có thể gọi API ngoài → hãy kiểm tra nguồn này
  • Bảo mật: cần quản lý chặt dữ liệu riêng tư và thông tin xác thực
  • Phạm vi: nhiều công cụ giúp LLM làm được nhiều hơn; lưu ý những gì mỗi máy chủ cung cấp

considerations.png

Giới thiệu về Model Context Protocol (MCP)

Open Library MCP

open-library.png

 

  • mcp-open-library: máy chủ MCP cho API Open Library của Internet Archive
  • Công cụ: get_book_by_title, get_authors_by_name, get_book_cover, get_book_by_id, ...
  • Không cần API key
1 https://github.com/8enSmith/mcp-open-library
Giới thiệu về Model Context Protocol (MCP)

Truy cập Open Library MCP

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

params = StdioServerParameters(
    command="open-library-server",
    args=[]
)
1 https://github.com/8enSmith/mcp-open-library?tab=readme-ov-file#installation
Giới thiệu về Model Context Protocol (MCP)

Sử dụng Open Library MCP

params = StdioServerParameters(command="open-library-server", args=[])


async with stdio_client(params) as (reader, writer): async with ClientSession(reader, writer) as session: await session.initialize()
response = await session.list_tools() print("Tools:", [t.name for t in response.tools]) result = await session.call_tool("get_book_by_title", {"title": "Dune"}) text = result.content[0].text print("Tool Call Result:", text)
Giới thiệu về Model Context Protocol (MCP)
Công cụ: ['get_book_by_title', 'get_authors_by_name', 'get_author_info',
'get_author_photo', 'get_book_cover', 'get_book_by_id']

Kết quả gọi công cụ: [ { "title": "Dune", "authors": [ "Frank Herbert" ], "first_publish_year": 1965, ... }, ...
Giới thiệu về Model Context Protocol (MCP)

Ayo berlatih!

Giới thiệu về Model Context Protocol (MCP)

Preparing Video For Download...