AWSのドキュメント検索MCPサーバーが最新ドキュメントを参照できる仕組み

AWSのドキュメント検索MCPサーバーが最新ドキュメントを参照できる仕組み

Clock Icon2025.04.07

AWSが2025年春にOSS公開したMCPサーバーの一つに、ドキュメント検索し、ベストプラクティスを回答してくれる AWS Documentation MCP Server というものがあります。

このMCPサーバーでは、MCP General architectureで言うところの リモートサービスへのWeb APIをMCPツールで実現 しています。

※ 引用 https://modelcontextprotocol.io/introduction

awslabs/mcp の場合、Web APIのリクエスト先となるリモートサービスとして

という2種類のエンドポイントを用意し、最新ドキュメントを検索・レコメンドできるようになっています。

MCPを使うためのClaude設定

実際に動作を確認するために、Claude DesktopをMCPと連携させましょう。

AWS Documentation MCP Server はPythonで実装されているため、 uv で実行環境を整えます

$ brew install uv
$ uv python install 3.13

MCP サーバーは、uvx から以下のようにして起動できます。

$ uvx awslabs.aws-documentation-mcp-server@latest

Transportレイヤーが stdio 方式のMCP では、MCPクライアントからサブプロセスとしてMCPサーバーを起動するため、MCPクライアントとなる Claude For Mac の Settings → Developer から以下の設定を追記します。

{
    "mcpServers": {
      "awslabs.aws-documentation-mcp-server": {
          "command": "/Users/ユーザー名/.local/bin/uvx",
          "args": ["awslabs.aws-documentation-mcp-server@latest"],
          "env": {
            "FASTMCP_LOG_LEVEL": "ERROR"
          },
          "disabled": false,
          "autoApprove": []
      }
    }
}

$ which uvx の結果に合わせて設定の command 行を uv の実際の絶対パスに合わせて下さい。

再起動すると、Settings 画面で "running" となっているはずです。

Claude のトップ画面からも、3つのMCPツールが見える様になっているはずです。

mcp server tool

具体的に検索してみましょう。

MCP設定を行った Claude for Mac(0.9.1)から "look up documentation on S3 bucket naming rule. cite your sources" と検索すると、以下の様な回答が返ってきました。青枠がMCPサーバーの介入です

mcp-tool-claude

以下の流れで回答を作成していることがわかります

  1. 検索サーバーにMCPサーバーツール経由で複数のドキュメントを検索(search_documentation)
    • 例) I'll search for AWS documentation on S3 bucket naming rules and share what I find with proper citations.
  2. マッチした各ドキュメントを整形して読み込む(read_documentation)
    • 例) Let me get the detailed documentation on general purpose bucket naming rules, which is most relevant to your question:
  3. 読み込んだ情報から回答を作成
    • 例) Based on the AWS documentation I've reviewed, here's a comprehensive summary of S3 bucket naming rules:

エージェント的にMCPクライアントが動くという点はあるけれども、ドキュメントを検索し、マッチしたドキュメントを元に回答を作成するという点は、シンプルなRAGと同じです。

最新の情報を参照できるのは、Web API問い合わせ先のAWSが提供する検索システムが最新の情報を持っているからです。

MCPサーバーでデバッグログを出力させると、MCPクライアントと連動するログを確認できます。

2025-04-06 13:57:25.727 | INFO     | __main__:main:417 - Starting AWS Documentation MCP Server
2025-04-06 13:57:25.727 | INFO     | __main__:main:425 - Using standard stdio transport
2025-04-06 13:57:36.504 | DEBUG    | __main__:search_documentation:232 - Searching AWS documentation for: S3 bucket naming rules
2025-04-06 13:57:38.007 | DEBUG    | __main__:search_documentation:307 - Found 5 search results for: S3 bucket naming rules
2025-04-06 13:57:45.535 | DEBUG    | __main__:read_documentation:150 - Fetching documentation from https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
2025-04-06 13:57:45.835 | DEBUG    | __main__:read_documentation:184 - Content truncated at 5000 of 10646 characters
2025-04-06 13:57:55.464 | DEBUG    | __main__:read_documentation:150 - Fetching documentation from https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
2025-04-06 13:57:55.690 | DEBUG    | __main__:read_documentation:184 - Content truncated at 10000 of 10646 characters
2025-04-06 13:58:01.452 | DEBUG    | __main__:read_documentation:150 - Fetching documentation from https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html

MCPツールの一般的なメッセージフローは以下の通りです


https://spec.modelcontextprotocol.io/specification/2025-03-26/server/tools/

今回の検証環境では、各アクターは以下のとおりです

  • LLM : Claude Sonnet 3.7
  • Client : Claude Desktop App
  • Server : awslabs.aws-documentation-mcp-server

リモートサービスとしてのAWSドキュメント検索システム

MCPクライアントとMCPサーバーのログの双方から、ツール search_documentationS3 bucket naming rules という検索語句でドキュメントを5件取得していることがわかります。

server.pysearch_document に関するコードが存在します。

    logger.debug(f'Searching AWS documentation for: {search_phrase}')

    request_body = {
        'textQuery': {
            'input': search_phrase,
        },
        'contextAttributes': [{'key': 'domain', 'value': 'docs.aws.amazon.com'}],
        'acceptSuggestionBody': 'RawText',
        'locales': ['en_us'],
    }

    async with httpx.AsyncClient() as client:
        try:
            response = await client.post(
                SEARCH_API_URL,
                json=request_body,
                headers={'Content-Type': 'application/json', 'User-Agent': DEFAULT_USER_AGENT},
                timeout=30,
            )

APIを投げる検索サーバーのURIはプログラム冒頭で宣言されています

SEARCH_API_URL = 'https://proxy.search.docs.aws.amazon.com/search'

MPC Server でログ出力させると、対応するログを確認できます。

2025-04-06 13:57:36.504 | DEBUG    | __main__:search_documentation:232 - Searching AWS documentation for: S3 bucket naming rules
2025-04-06 13:57:38.007 | DEBUG    | __main__:search_documentation:307 - Found 5 search results for: S3 bucket naming rules

MCP Client(Claude)上からは、MCP Client(エージェント)の検索サーバーへのリクエストとレスポンスを確認できます

# リクエスト

I'll search for AWS documentation on S3 bucket naming rules and share what I find with proper citations.

{
  `limit`: 5,
  `search_phrase`: `S3 bucket naming rules`
}

# レスポンス

{
  "rank_order": 1,
  "url": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-buckets-naming.html",
  "title": "Amazon S3 table bucket, table, and namespace naming rules - Amazon Simple Storage Service",
  "context": "Use the table bucket naming rules to create table buckets and name tables and namespaces in Amazon S3 Tables."
}
{
  "rank_order": 2,
  "url": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-bucket-naming-rules.html",
  "title": "Directory bucket naming rules - Amazon Simple Storage Service",
  "context": "Use the directory bucket naming rules when you create a directory bucket in Amazon S3."
}
...

cURL からリクエストを確認

これらを元に、AWSドキュメント検索のリモートサービスへの問い合わせをcURL コマンドに移植できます。

検索結果が早いものから順に、1-indexで rank_order を付与しているようです。

$ curl -X POST https://proxy.search.docs.aws.amazon.com/search \
  -H "Content-Type: application/json" \
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 ModelContextProtocol/1.0 (AWS Documentation Server)" \
  -d '{
    "textQuery": {
      "input": "S3 bucket naming rules"
    },
    "contextAttributes": [
      {
        "key": "domain",
        "value": "docs.aws.amazon.com"
      }
    ],
    "acceptSuggestionBody": "RawText",
    "locales": ["en_us"]
  }'

{
  "queryId": "40dd0cc1-4e0f-42af-9385-a1878fe3cbb5",
  "suggestions": [
    {
      "textExcerptSuggestion": {
        "link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-buckets-naming.html",
        "title": "Amazon S3 table bucket, table, and namespace naming rules - Amazon Simple Storage Service",
        "suggestionBody": "For general purpose bucket naming rules, see General purpose bucket naming rules. For directory bucket naming rules, see Directory bucket naming rules.",
        "summary": "Use the table bucket naming rules to create table buckets and name tables and namespaces in Amazon S3 Tables.",
        "context": [
          {
            "key": "aws-docs-search-product",
            "value": "Amazon Simple Storage Service"
          },
          {
            "key": "domain",
            "value": "docs.aws.amazon.com"
          },
          {
            "key": "document-type",
            "value": "documentation"
          },
          {
            "key": "publisher",
            "value": "aws"
          },
          {
            "key": "aws-docs-search-guide",
            "value": "User Guide"
          },
          {
            "key": "programming-language",
            "value": "javascript"
          }
        ],
        "sourceUpdatedAt": 1741901134584,
        "isCitable": true
      }
    },
    {
      "textExcerptSuggestion": {
        "link": "https://docs.aws.amazon.com/AmazonS3/latest/userguide/directory-bucket-naming-rules.html",
        "title": "Directory bucket naming rules - Amazon Simple Storage Service",
        "suggestionBody": "When you create a directory bucket in Amazon S3, the following bucket naming rules apply. For general purpose bucket naming rules, see General purpose bucket naming rules.",
        "summary": "Use the directory bucket naming rules when you create a directory bucket in Amazon S3.",
        "context": [
          {
            "key": "domain",
            "value": "docs.aws.amazon.com"
          },
          {
            "key": "programming-language",
            "value": "javascript"
          },
          {
            "key": "document-type",
            "value": "documentation"
          },
          {
            "key": "publisher",
            "value": "aws"
          },
          {
            "key": "aws-docs-search-guide",
            "value": "User Guide"
          },
          {
            "key": "aws-docs-search-product",
            "value": "Amazon Simple Storage Service"
          }
        ],
        "sourceUpdatedAt": 1743438752030,
        "isCitable": true
      }
    },
...

MCPサーバーは情報検索システムへの薄いラッパーであることがわかります。

MCPのドキュメント検索も結局はRAGと同じく情報検索(information retrieval;IR)の世界

翻って、AWS Documentation MCP Serverを参考にMCPベースのドキュメント検索システムを作るとしましょう。

ソースコードやMCPの仕様からもわかるように、MCPサーバーの実装は薄いです。

重い実装はなにかというと、リモートサービス化されたブラックボックスな 情報検索システム です。

AWS の実装では、以下の2つのエンドポイントが用意されています。

日々更新されるドキュメントをタイムリーにインデクシングし、検索フレーズに対して適切なドキュメントを返すようなドキュメント検索システムがなければ、MCPサーバーをそれっぽく作って、MCPクライアントに割り込んでも、実用的な検索システムとはなりません。

構造的に Retrieval Augmented Generation(RAG)の Retrieval(R) フェーズと同じ問題を抱えています。

情報検索(Information Retrieval/IR)と向き合いましょう。

参考

付録:検証環境

  • LLM : Claude Sonnet 3.7
  • MCP Client : Claude for Mac(0.9.1)
  • MCP Server : AWS Documentation MCP Server@v0.0.1
  • Claude for Mac(0.9.1)
  • Python 3.13
  • Python パッケージマネージャー uv
  • 実行環境 : macOS

付録:MCP クライアント と MCP サーバーのプロセス関係

今回は stdio トランスポートを利用しているため、MCP クライアント(PID 23475のClaude)の子プロセスとして、MCP サーバー(awslabs.aws-documentation-mcp-server) が uv 経由で起動します。

$ pstree -p 23475 -w
-+= 00001 root /sbin/launchd
 \-+= 23475 jsmith /Applications/Claude.app/Contents/MacOS/Claude
   ...
   |-+- 23486 jsmith /Users/jsmith/.local/bin/uv tool uvx awslabs.aws-documentation-mcp-server@latest
   | \--- 23490 jsmith /Users/jsmith/.cache/uv/archive-v0/vef7Lv3g_fCP_OsyVDI4B/bin/python /Users/jsmith/.cache/uv/archive-v0/vef7Lv3g_fCP_OsyVDI4B/bin/awslabs.aws-documentation-mcp-server
   ...
   \--- 23498 jsmith /Applications/Claude.app/Contents/Frameworks/Claude Helper ...

付録:検索サーバーはAmazon API Gateway製

検索エンドポイントのレスポンスから、API Gatewayで実装されていることがわかります

$ curl -I https://proxy.search.docs.aws.amazon.com/search
HTTP/2 403
date: Mon, 07 Apr 2025 06:06:43 GMT
content-type: application/json
content-length: 0
x-amzn-requestid: c047820a-51c9-4c69-82a3-cf854a06f816
x-amzn-errortype: MissingAuthenticationTokenException
x-amz-apigw-id: Io26JGiUPHcEMmw=

2025/04/07 時点ではパブリックに公開されていますが、今後、どのように認証・認可が実装されるのか、気になります。

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.