Model Context Protocol.

MCPとは

A protocol for seamless integration between LLM applications and external data sources.

  • 2024年11月に、Anthropicが発表したクライアント-サーバー間通信のプロトコル.
  • 通信プロトコルを定め、LLMにコンテキストを渡す方法を標準化することが目的.
  • 自然言語で指示できるLLMのための🔌API.
  • AIアプリケーション用のUSB-Cポートのようなもの
  • AI がシステムにアクセスする時の「接続のしかた」をルール化したもの

https://github.com/modelcontextprotocol

できること

  • ファイルアクセス
  • Webアクセス/ブラウザ操作

Core Architecture

  • Hosts are LLM applications (like Claude Desktop or IDEs) that initiate connections
  • Clients maintain 1:1 connections with servers, inside the host application
  • Servers provide context, tools, and prompts to clients
  • Local Data Sources: Your computer’s files, databases, and services that MCP servers can securely access
  • Remote Services: External systems available over the internet (e.g., through APIs) that MCP servers can connect to

☁クライアントサーバモデル(Client/Server)

ref. Core architecture - Model Context Protocol

Core components

  • プロトコル層(Protocol layer): メッセージのフレーミング、リクエスト/レスポンスの関連付け、高レベルな通信パターンを扱う
  • トランスポート層(Transport layer): クライアントとサーバー間の実際の通信を扱う
  • メッセージタイプ: リクエスト(Request): 応答を期待するメッセージ。method とオプションの params を含む

Transport Layer

  • JSON-RPC 2.0

MCP Servers

データソース側

Functions

3つの主要機能.

  • Model(AI モデルのための)
  • Context(提示されるサービスの情報・利用方法などの)
  • Protocol(共通ルール)

Index

https://github.com/modelcontextprotocol/servers

dev

Smithery

Docker MCP(Docker Desktop/AI Tools)

これはdockerの操作というよりも、dockerをつかったローカルMCP server構築.

Refs

MCP Hosts

LLM applications that initiate connections.

現状ではこの3つが三強.

MCP Client

Specs

Topics

npx vs npm install

基本方針はnpx.

  • npx
    • 自動アップデート. 定期的なupdate不要.
    • ネットが必要.
    • 数秒起動が遅い.
  • npm i
    • オフラインで利用できる
    • 数秒npxよりも早い.