0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

MCPについて整理してみた

Posted at

背景・目的

少し遅いですが、MCP(Model Context Protocol)について、整理し理解します。

まとめ

下記に特徴を整理します。

特徴 説明
MCPとは Model Context Protocol
下記などのデータが存在するシステムにAIアシスタントを接続するために、MCPをOSS化した
・コンテンツ
・リポジトリ
・ビジネスツール
・開発環境
目的 モデルがより優れた、より適切な応答を生成できるように支援すること
背景 最も洗練されたモデルであっても、情報サイロやレガシー システムの背後に閉じ込められ、データから分離されているという制約があった
新しいデータ ソースごとに独自のカスタム実装が必要になるため、真に接続されたシステムを拡張することが困難
ソリューション AI システムとデータ ソースを接続するための普遍的なオープン スタンダードを提供し、断片化された統合を単一のプロトコルに置き換える
その結果、AI システムに必要なデータへのアクセスを提供するための、よりシンプルで信頼性の高い方法が実現する
アーキテクチャ ホスト アプリケーションが複数のサーバーに接続できるクライアント サーバー アーキテクチャに従う

下記の役割(概念)がある
・MCP Hosts
・MCP Clients
・MCP Servers
・Local Data Sources
・Remote Services
MCP Hosts Claude Desktop、IDE、またはMCPを介してデータにアクセスするAIツールなどのプログラム
MCP Clients サーバーとの1:1接続を維持するプロトコルクライアント
MCP Servers 標準化されたモデルコンテキストプロトコルを通じて特定の機能を公開する軽量プログラム
Local Data Sources MCPサーバーが安全にアクセスできるコンピュータのファイル、データベース、サービス
Remote Services MCP サーバーが接続できるインターネット経由 (API 経由など) で利用可能な外部システム
設計原則 1.サーバーの構築は非常に簡単であるべきである
2.サーバーは高度に構成可能である必要がある
3.サーバーは会話全体を読んだり、他のサーバーを「覗き見る」ことはできない
4.サーバーとクライアントに段階的に機能を追加できる

概要

Introducing the Model Context Protocol

下記を基に整理します。

Today, we're open-sourcing the Model Context Protocol (MCP), a new standard for connecting AI assistants to the systems where data lives, including content repositories, business tools, and development environments. Its aim is to help frontier models produce better, more relevant responses.

  • Model Context Protocolのこと
  • 下記などのデータが存在するシステムにAIアシスタントを接続するために、MCPをOSS化した
    • コンテンツ
    • リポジトリ
    • ビジネスツール
    • 開発環境
  • 目的は、フロンティア モデルがより優れた、より適切な応答を生成できるように支援すること

As AI assistants gain mainstream adoption, the industry has invested heavily in model capabilities, achieving rapid advances in reasoning and quality. Yet even the most sophisticated models are constrained by their isolation from data—trapped behind information silos and legacy systems. Every new data source requires its own custom implementation, making truly connected systems difficult to scale.

  • (これまで)AI アシスタントが主流に採用されるにつれて、業界はモデル機能に多額の投資を行い、推論と品質の急速な進歩を達成した
  • (課題1)最も洗練されたモデルであっても、情報サイロやレガシー システムの背後に閉じ込められ、データから分離されているという制約がある
  • (課題2)新しいデータ ソースごとに独自のカスタム実装が必要になるため、真に接続されたシステムを拡張することが困難

MCP addresses this challenge. It provides a universal, open standard for connecting AI systems with data sources, replacing fragmented integrations with a single protocol. The result is a simpler, more reliable way to give AI systems access to the data they need.

  • (解決方法)MCP はこの課題に対処する
    • AI システムとデータ ソースを接続するための普遍的なオープン スタンダードを提供し、断片化された統合を単一のプロトコルに置き換える
    • その結果、AI システムに必要なデータへのアクセスを提供するための、よりシンプルで信頼性の高い方法が実現する

Model Context Protocol

The Model Context Protocol is an open standard that enables developers to build secure, two-way connections between their data sources and AI-powered tools. The architecture is straightforward: developers can either expose their data through MCP servers or build AI applications (MCP clients) that connect to these servers.

  • MCPは、開発者がデータ ソースと AI 搭載ツールの間に安全な双方向接続を構築できるようにするオープン スタンダード
  • アーキテクチャは単純。開発者は、MCP サーバーを通じてデータを公開するか、これらのサーバーに接続する AI アプリケーション (MCP クライアント) を構築できる

Today, we're introducing three major components of the Model Context Protocol for developers:

  • The Model Context Protocol specification and SDKs
  • Local MCP server support in the Claude Desktop apps
  • An open-source repository of MCP servers
  • 3 つの主要コンポーネント
    • モデルコンテキストプロトコル仕様とSDK
    • Claude デスクトップ アプリでのローカル MCP サーバーのサポート
    • MCP サーバーのオープンソースリポジトリ

Claude 3.5 Sonnet is adept at quickly building MCP server implementations, making it easy for organizations and individuals to rapidly connect their most important datasets with a range of AI-powered tools. To help developers start exploring, we’re sharing pre-built MCP servers for popular enterprise systems like Google Drive, Slack, GitHub, Git, Postgres, and Puppeteer.

  • Claude 3.5 Sonnet は、MCP サーバーの実装を迅速に構築することに長けており、組織や個人がさまざまな AI 搭載ツールに最も重要なデータセットを迅速に接続することを容易にする
  • 開発者が探索を始められるように、Google ドライブ、Slack、GitHub、Git、Postgres、Puppeteer などの一般的なエンタープライズ システム向けに構築済みの MCP サーバーを共有している

Early adopters like Block and Apollo have integrated MCP into their systems, while development tools companies including Zed, Replit, Codeium, and Sourcegraph are working with MCP to enhance their platforms—enabling AI agents to better retrieve relevant information to further understand the context around a coding task and produce more nuanced and functional code with fewer attempts.

  • Block や Apollo などのアーリーアダプターは MCP を自社のシステムに統合
  • Zed、Replit、Codeium、Sourcegraph などの開発ツール企業は MCP と連携して自社のプラットフォームを強化し、AI エージェントが関連情報をより適切に取得してコーディング タスクのコンテキストをさらに理解し、より少ない試行でよりニュアンスに富んだ機能的なコードを生成できるようにしている

Instead of maintaining separate connectors for each data source, developers can now build against a standard protocol. As the ecosystem matures, AI systems will maintain context as they move between different tools and datasets, replacing today's fragmented integrations with a more sustainable architecture.

  • 開発者は、データソースごとに個別のコネクタを管理する代わりに、標準プロトコルに基づいて開発を行うことができる
  • エコシステムが成熟するにつれて、AIシステムは異なるツールやデータセット間を移動する際にコンテキストを維持し、現在の断片化された統合をより持続可能なアーキテクチャに置き換えることができる

Introduction

下記を基に整理します

Why MCP?

MCP helps you build agents and complex workflows on top of LLMs. LLMs frequently need to integrate with data and tools, and MCP provides:

  • A growing list of pre-built integrations that your LLM can directly plug into
  • The flexibility to switch between LLM providers and vendors
  • Best practices for securing your data within your infrastructure
  • MCPは、LLM上にエージェントと複雑なワークフローを構築するのに役立つ。LLMはデータやツールとの統合が頻繁に必要となるが、MCPは以下の機能を提供する
    • LLMに直接接続できる、構築済みの統合のリスト
    • LLMプロバイダーとベンダーを切り替える柔軟性
    • インフラストラクチャ内でデータを保護するためのベストプラクティス

General architecture

At its core, MCP follows a client-server architecture where a host application can connect to multiple servers:

  • MCP は基本的に、ホスト アプリケーションが複数のサーバーに接続できるクライアント サーバー アーキテクチャに従う

image.png

出典:General architecture

  • MCP Hosts: Programs like Claude Desktop, IDEs, or AI tools that want to access data through MCP
  • MCP Clients: Protocol clients that maintain 1:1 connections with servers
  • MCP Servers: Lightweight programs that each expose specific capabilities through the standardized Model Context Protocol
  • 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
  • MCP Hosts
    • Claude Desktop、IDE、またはMCPを介してデータにアクセスするAIツールなどのプログラム
  • MCP Clients
    • サーバーとの1:1接続を維持するプロトコルクライアント
  • MCP Servers
    • 標準化されたモデルコンテキストプロトコルを通じて特定の機能を公開する軽量プログラム
  • Local Data Sources
    • MCPサーバーが安全にアクセスできるコンピュータのファイル、データベース、サービス
  • Remote Services
    • MCP サーバーが接続できるインターネット経由 (API 経由など) で利用可能な外部システム

Specification

下記を基に整理します

Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you’re building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need.

  • モデル コンテキスト プロトコル (MCP) は、LLM アプリケーションと外部データ ソースおよびツール間のシームレスな統合を可能にするオープン プロトコル
  • AI 搭載 IDE の構築、チャット インターフェースの強化、カスタム AI ワークフローの作成など、MCP は LLM を必要なコンテキストに接続するための標準化された方法を提供

This specification defines the authoritative protocol requirements, based on the TypeScript schema in schema.ts.

  • この仕様は、schema.ts の TypeScript スキーマに基づいて、信頼できるプロトコルの要件を定義

Overview

MCP provides a standardized way for applications to:

  • Share contextual information with language models
  • Expose tools and capabilities to AI systems
  • Build composable integrations and workflows
  • MCP は、アプリケーションに次のことを実行する標準化された方法を提供する
    • 言語モデルとコンテキスト情報を共有する
    • AIシステムにツールと機能を公開する
    • 構成可能な統合とワークフローを構築する

The protocol uses JSON-RPC 2.0 messages to establish communication between:

  • Hosts: LLM applications that initiate connections
  • Clients: Connectors within the host application
  • Servers: Services that provide context and capabilities
  • このプロトコルはJSON-RPC 2.0メッセージを使用
    • Hosts: 接続を開始する LLM アプリケーション
    • Clients:ホストアプリケーション内のコネクタ
    • Servers:コンテキストと機能を提供するサービス

MCP takes some inspiration from the Language Server Protocol, which standardizes how to add support for programming languages across a whole ecosystem of development tools. In a similar way, MCP standardizes how to integrate additional context and tools into the ecosystem of AI applications.

  • MCP は、開発ツールのエコシステム全体にわたってプログラミング言語のサポートを追加する方法を標準化する言語サーバー プロトコルからインスピレーションを得ている
  • 同様に、MCP は追加のコンテキストとツールを AI アプリケーションのエコシステムに統合する方法を標準化する

Key Details

Base Protocol

  • JSON-RPC message format
  • Stateful connections
  • Server and client capability negotiation

Features

Servers offer any of the following features to clients:

  • Resources: Context and data, for the user or the AI model to use
  • Prompts: Templated messages and workflows for users
  • Tools: Functions for the AI model to execute
  • サーバーはクライアントに以下の機能を提供
    • Resources
      • ユーザーまたはAIモデルが使用するコンテキストとデータ
    • Prompts
      • ユーザー向けのテンプレート化されたメッセージとワークフロー
    • Tools
      • AIモデルが実行する関数

Clients may offer the following feature to servers:

  • Sampling: Server-initiated agentic behaviors and recursive LLM interactions
  • クライアントはサーバーに次の機能を提供することができる
    • サーバー主導のエージェント行動と再帰的なLLMインタラクション

Security and Trust & Safety

The Model Context Protocol enables powerful capabilities through arbitrary data access and code execution paths. With this power comes important security and trust considerations that all implementors must carefully address.

  • モデルコンテキストプロトコルは、任意のデータアクセスとコード実行パスを通じて強力な機能を実現する
  • この強力な機能には、すべての実装者が慎重に対処しなければならない重要なセキュリティと信頼性の考慮事項が伴う

Key Principles

User Consent and Control
  • Users must explicitly consent to and understand all data access and operations
  • Users must retain control over what data is shared and what actions are taken
  • Implementors should provide clear UIs for reviewing and authorizing activities
  • ユーザーは、すべてのデータアクセスと操作に明示的に同意し、理解する必要がある
  • ユーザーは、どのデータが共有され、どのようなアクションが実行されるかについて制御を維持する必要がある
  • 実装者は、アクティビティの確認と承認のための明確なUIを提供する必要がある
Data Privacy
  • Hosts must obtain explicit user consent before exposing user data to servers
  • Hosts must not transmit resource data elsewhere without user consent
  • User data should be protected with appropriate access controls
  • ホストは、ユーザーデータをサーバーに公開する前に、ユーザーの明示的な同意を得る必要がある
  • ホストはユーザーの同意なしにリソースデータを他の場所に送信してはならない
  • ユーザーデータは適切なアクセス制御によって保護される必要がある
Tool Safety
  • Tools represent arbitrary code execution and must be treated with appropriate caution.
    • In particular, descriptions of tool behavior such as annotations should be considered untrusted, unless obtained from a trusted server.
  • Hosts must obtain explicit user consent before invoking any tool
  • Users should understand what each tool does before authorizing its use
  • ツールは任意のコード実行を表すものであり、適切な注意を払って扱う必要がある
    • 特に、注釈などのツールの動作の説明は、信頼できるサーバーから取得されない限り、信頼できないものとみなされるべきである
  • ホストはツールを呼び出す前にユーザーの明示的な同意を得る必要がある
  • ユーザーは、使用を許可する前に各ツールの機能を理解する必要がある
LLM Sampling Controls
  • Users must explicitly approve any LLM sampling requests
  • Users should control:
    • Whether sampling occurs at all
    • The actual prompt that will be sent
    • What results the server can see
  • The protocol intentionally limits server visibility into prompts
  • ユーザーはLLMのサンプリングリクエストを明示的に承認する必要がある
  • ユーザーは下記を制御する必要がある
    • サンプリングが行われるかどうか
    • 実際に送信されるプロンプト
    • サーバーが確認できる結果
  • このプロトコルは、プロンプトへのサーバーの可視性を意図的に制限している

Architecture

下記を基に整理します

実践

Getting started

The Model Context Protocol (MCP) follows a client-host-server architecture where each host can run multiple client instances. This architecture enables users to integrate AI capabilities across applications while maintaining clear security boundaries and isolating concerns. Built on JSON-RPC, MCP provides a stateful session protocol focused on context exchange and sampling coordination between clients and servers.

  • モデル コンテキスト プロトコル (MCP) は、各ホストが複数のクライアント インスタンスを実行できるクライアント ホスト サーバー アーキテクチャに従う
  • このアーキテクチャにより、ユーザーは明確なセキュリティ境界を維持し、懸念事項を分離しながら、アプリケーション間で AI 機能を統合できる
  • JSON-RPC 上に構築された MCP は、クライアントとサーバー間のコンテキスト交換とサンプリング調整に重点を置いたステートフル セッション プロトコルを提供

core-components

image.png

出典:core-components

  • The host process acts as the container and coordinator:
    • Creates and manages multiple client instances
    • Controls client connection permissions and lifecycle
    • Enforces security policies and consent requirements
    • Handles user authorization decisions
    • Coordinates AI/LLM integration and sampling
    • Manages context aggregation across clients

Host

  • ホストプロセスはコンテナとコーディネーターとして機能する
    • 複数のクライアントインスタンスを作成および管理
    • クライアント接続の権限とライフサイクルを制御する
    • セキュリティポリシーと同意要件を強制する
    • ユーザーの承認決定を処理する
    • AI/LLMの統合とサンプリングを調整
    • クライアント間のコンテキスト集約を管理します

Clients

Each client is created by the host and maintains an isolated server connection:

  • Establishes one stateful session per server
  • Handles protocol negotiation and capability exchange
  • Routes protocol messages bidirectionally
  • Manages subscriptions and notifications
  • Maintains security boundaries between servers

A host application creates and manages multiple clients, with each client having a 1:1 relationship with a particular server.

  • 各クライアントはホストによって作成され、分離されたサーバー接続を維持する
    • サーバーごとに1つのステートフルセッションを確立
    • プロトコルネゴシエーションと機能交換を処理する
    • プロトコルメッセージを双方向にルーティングする
    • サブスクリプションと通知を管理する
    • サーバー間のセキュリティ境界を維持する

Servers

Servers provide specialized context and capabilities:

  • Expose resources, tools and prompts via MCP primitives
  • Operate independently with focused responsibilities
  • Request sampling through client interfaces
  • Must respect security constraints
  • Can be local processes or remote services
  • サーバーは特殊なコンテキストと機能を提供する
    • MCPプリミティブを介してリソース、ツール、プロンプトを公開する
    • 責任を明確にして独立して業務を遂行する
    • クライアントインターフェースを通じてサンプリングを要求する
    • セキュリティ制約を尊重する必要がある
    • ローカルプロセスまたはリモートサービスにすることができる

Design Principles

MCP is built on several key design principles that inform its architecture and implementation:

  • MCPは、そのアーキテクチャと実装を規定するいくつかの重要な設計原則に基づいて構築されている
  1. Servers should be extremely easy to build
  • Host applications handle complex orchestration responsibilities
  • Servers focus on specific, well-defined capabilities
  • Simple interfaces minimize implementation overhead
  • Clear separation enables maintainable code
  1. サーバーの構築は非常に簡単であるべきである
    • ホストアプリケーションは複雑なオーケストレーションの責任を担いま
    • サーバーは明確に定義された特定の機能に注力します
    • シンプルなインターフェースにより実装のオーバーヘッドを最小限に抑えます
    • 明確な分離により保守性の高いコードを実現します

2.Servers should be highly composable

  • Each server provides focused functionality in isolation
  • Multiple servers can be combined seamlessly
  • Shared protocol enables interoperability
  • Modular design supports extensibility

2.サーバーは高度に構成可能である必要がある

  • 各サーバーはそれぞれ独立した機能を提供します
  • 複数のサーバーをシームレスに組み合わせることができます
  • 共有プロトコルにより相互運用性が実現します
  • モジュール設計により拡張性をサポートします

3.Servers should not be able to read the whole conversation, nor “see into” other servers

  • Servers receive only necessary contextual information
  • Full conversation history stays with the host
  • Each server connection maintains isolation
  • Cross-server interactions are controlled by the host
  • Host process enforces security boundaries

3.サーバーは会話全体を読んだり、他のサーバーを「覗き見る」ことはできない

  • サーバーは必要なコンテキスト情報のみを受信します
  • 完全な会話履歴はホストに保持されます
  • 各サーバー接続は分離を維持します
  • サーバー間のやり取りはホストによって制御されます
  • ホストプロセスはセキュリティ境界を強化します

4.Features can be added to servers and clients progressively

  • Core protocol provides minimal required functionality
  • Additional capabilities can be negotiated as needed
  • Servers and clients evolve independently
  • Protocol designed for future extensibility
  • Backwards compatibility is maintained

4.サーバーとクライアントに段階的に機能を追加できる

  • コアプロトコルは必要最小限の機能を提供します
  • 必要に応じて追加機能をネゴシエートできます
  • サーバーとクライアントは独立して進化します
  • 将来の拡張性を考慮して設計されたプロトコル
  • 下位互換性が維持されます

Capability Negotiation

The Model Context Protocol uses a capability-based negotiation system where clients and servers explicitly declare their supported features during initialization. Capabilities determine which protocol features and primitives are available during a session.

  • Servers declare capabilities like resource subscriptions, tool support, and prompt templates
  • Clients declare capabilities like sampling support and notification handling
  • Both parties must respect declared capabilities throughout the session
  • Additional capabilities can be negotiated through extensions to the protocol
  • モデルコンテキストプロトコルは、クライアントとサーバーが初期化時にサポートする機能を明示的に宣言する、機能ベースのネゴシエーションシステムを採用

  • 機能は、セッション中に利用可能なプロトコル機能とプリミティブを決定する

  • サーバーは、リソースサブスクリプション、ツールサポート、プロンプトテンプレートなどの機能を宣言

  • クライアントは、サンプリングサポートや通知処理などの機能を宣言

  • セッション全体を通して、双方は宣言された機能を尊重する必要がある

  • 追加の機能は、プロトコルの拡張を通じてネゴシエートできる

image.png
出典:Capability Negotiation

Each capability unlocks specific protocol features for use during the session. For example:

  • Implemented server features must be advertised in the server’s capabilities
  • Emitting resource subscription notifications requires the server to declare subscription support
  • Tool invocation requires the server to declare tool capabilities
  • Sampling requires the client to declare support in its capabilities

This capability negotiation ensures clients and servers have a clear understanding of supported functionality while maintaining protocol extensibility.

各機能は、セッション中に使用できる特定のプロトコル機能のロックを解除する

  • 実装されたサーバー機能は、サーバーの機能でアドバタイズする必要がある
  • リソースサブスクリプション通知を発行するには、サーバーがサブスクリプションのサポートを宣言する必要がある
  • ツールを呼び出すには、サーバーがツールの機能を宣言する必要がある
  • サンプリングを行うには、クライアントが機能でサポートを宣言する必要がある

この機能ネゴシエーションにより、プロトコルの拡張性を維持しながら、クライアントとサーバーがサポートされている機能を明確に理解できるようになる

考察

今回は、MCP(Model Context Protocol)に付いて整理しました。次回は、実際にClaudeまたはOpenAIの環境を使ってMCP Serverを構築し、RAGツールとの連携を検証してみたいと思います。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?