
TV放送の情報を返すモックMCPサーバーをAgent Coreで構築してDevOps Agentのインシデント調査に活用できないか検証してみた
リテールアプリ共創部@大阪の岩田です。
Agent Coreで自作したMCPサーバーをDevOps Agentの調査用に活用できないか検証してみたので内容についてご紹介します。
MCPサーバーを自作するモチベーション
DevOps Agentは2026年1月現在でまだプレビューリリース状態ではありますが、非常に便利なサービスです。
ちょっと指示しただけで各種AWSリソースのメトリクスやログを調べてインシデントに関する有益な情報を提供してくれるため非常に重宝しています。
ただし、インシデントの原因全てがAWS内で取得できるわけではありません。現実のシナリオではTV放送やSNS、集客のためのメルマガ配信といった様々なイベントを契機にスパイクアクセスが発生してシステムが過負荷に陥ることが考えられます。
これらのイベントの発生は、いくらAWSリソースのメトリクスやログを調査しても分かりません。
もしTV放送の予定を管理しているデータベースがあれば、その情報をMCPサーバー経由で取得できるようにしておくことでDevOps Agentの調査に役立つのでは?
と考え、簡易な構成で検証してみることにしました。
DevOps Agentで利用できるMCPサーバーの要件
まずDevOps Agentで利用可能なMCPサーバーには要件があります。
あくまでプレビュー段階である現時点においてですが、ドキュメントには以下のように記載されています。
Publicly accessible endpoint – MCP servers must be accessible from the public internet over HTTPS. AWS DevOps Agent does not support connecting to servers hosted in VPCs.
Streamable HTTP transport protocol – Only MCP servers that implement the Streamable HTTP transport protocol are supported.
Authentication support – Your MCP server must support OAuth 2.0 authentication flows or API key/token-based authentication.
Connecting MCP Servers - AWS DevOps Agent
この要件を見る限りAgentCoreを使うとサクッと要件を満たす構成が作れそうですね。
ということでAgent Coreを使って以下のような構成を作ってみます。
DevOps Agent → AgentCore Gateway → API Gateway(レスポンスストリーミング) → Lambda(レスポンスストリーミング)
やってみる
それではTV放送の予定を取得できるMCPサーバーを作っていきましょう!
Lambda Functionの用意
まずLambda Functionを用意します。今回は検証目的なので以下のような簡易なコードとしました。
import { pipeline } from 'node:stream/promises';
import { Readable } from 'node:stream';
export const lambdaHandler = awslambda.streamifyResponse(async (event, responseStream, _context) => {
const metadata = {
statusCode: 200,
headers: {
"Content-Type": "text/event-stream; charset=utf-8",
}
};
responseStream = awslambda.HttpResponseStream.from(responseStream, metadata);
const readable = Readable.from([
"TV放送があったのは以下の日付です\n",
"2026-01-01T10:00:00+09:00 ~ 2026-01-01T10:10:00+09:00 著名な芸能人によって紹介されました \n",
"2026-01-02T11:00:00+09:00 ~ 2026-01-02T11:10:00+09:00 著名なアイドルによって紹介されました \n",
"2026-01-07T13:20:00+09:00 ~ 2026-01-07T13:40:00+09:00 著名なタレントによって紹介されました \n",
]);
await pipeline(readable, responseStream);
});
実際にはTV放送予定を格納している何らかのデータベースから情報を取得する想定ですが、オンコードでTV放送の予定を列挙するだけの実装としています。
あとはストリームレスポンスを利用するためにawslambda.streamifyResponseを使っているぐらいで、特に難しいことはしていません。
SAMテンプレートをデプロイ
Lambdaが実装できたので諸々のAWSリソースをSAMテンプレートでデプロイします。
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
Domain:
Type: String
Description: Cognitoユーザープール用のドメイン
Globals:
Function:
Timeout: 600
Tracing: Active
Api:
TracingEnabled: true
Resources:
McpFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: mcp/
Handler: app.lambdaHandler
Runtime: nodejs24.x
Architectures:
- x86_64
Events:
mcp:
Type: Api
Properties:
Path: /mcp
Method: get
RestApiId: !Ref McpApi
McpApi:
Type: AWS::Serverless::Api
Properties:
StageName:
prd
DefinitionBody:
openapi: "3.0.1"
info:
title: "stream-mcp"
version: "1.0"
servers: []
paths:
/mcp:
get:
summary: Get TV broadcast information
description: |-
Get information such as when it was broadcast on TV and who featured it.
operationId: getTVBroadcastInfo
x-amazon-apigateway-integration:
type: "aws_proxy"
uri:
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2021-11-15/functions/${McpFunction.Arn}/response-streaming-invocations
httpMethod: "POST"
passthroughBehavior: "when_no_match"
responseTransferMode: "STREAM"
contentHandling: "CONVERT_TO_TEXT"
responses:
"200":
description: TV broadcast information retrieved successfully
content:
text/event-stream:
schema:
type: string
security:
- sigv4: []
components:
securitySchemes:
sigv4:
type: apiKey
name: Authorization
in: header
x-amazon-apigateway-authtype: awsSigv4
Gateway:
Type: AWS::BedrockAgentCore::Gateway
Properties:
AuthorizerType: CUSTOM_JWT
AuthorizerConfiguration:
CustomJWTAuthorizer:
DiscoveryUrl: !Sub https://cognito-idp.${AWS::Region}.amazonaws.com/${AgentCoreGWUserPool}/.well-known/openid-configuration
AllowedClients:
- !Ref AgentCoreGWClient
Description: DevOps Agentと連携させるためのゲートウェイ
Name: gateway-for-devops-agent
ProtocolType: MCP
RoleArn: !GetAtt GatewayRole.Arn
ExceptionLevel: DEBUG
# GatewayTarget:
# Type: AWS::BedrockAgentCore::GatewayTarget
# Properties:
# CredentialProviderConfigurations:
# - CredentialProviderType: GATEWAY_IAM_ROLE
# GatewayIdentifier: !Ref Gateway
# Name: api-gateway-target
# TargetConfiguration:
# ターゲットにAPI GWを指定するのはCloud Formationがまだ未対応なので手動で設定する
GatewayRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: bedrock-agentcore.amazonaws.com
Action:
- sts:AssumeRole
Policies:
- PolicyName: GatewayRolePolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- execute-api:Invoke
Resource:
- !Sub arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${McpApi}/*
AgentCoreGWUserPool:
Type: AWS::Cognito::UserPool
AgentCoreGWResourceServer:
Type: AWS::Cognito::UserPoolResourceServer
Properties:
Identifier: gateway
Name: gateway
Scopes:
- ScopeName: genesis-gateway:invoke
ScopeDescription: Scope for invoking the genesis gateway
UserPoolId: !Ref AgentCoreGWUserPool
AgentCoreGWClient:
Type: AWS::Cognito::UserPoolClient
Properties:
UserPoolId: !Ref AgentCoreGWUserPool
GenerateSecret: true
SupportedIdentityProviders:
- COGNITO
AllowedOAuthFlows:
- client_credentials
AllowedOAuthFlowsUserPoolClient: true
AllowedOAuthScopes:
- gateway/genesis-gateway:invoke
DependsOn: AgentCoreGWResourceServer
AgentCoreGWUserPoolDomain:
Type: AWS::Cognito::UserPoolDomain
Properties:
UserPoolId: !Ref AgentCoreGWUserPool
Domain: !Ref Domain
AgentCoreのゲートウェイターゲットもまとめて作りたかったのですが、現時点ではCloudFormationがAPI GWのターゲットに未対応なので後から手動作成することにしました。
このテンプレートをsam buildとsam deployでデプロイします。
ゲートウェイのターゲットを手動作成
デプロイできたらゲートウェイターゲットを手動で作成していきます。

API GW側でIAM認可を有効化しているので、アウトバウンド認証設定はIAMロールを選択します。
ここまでできたらMCP Inspectorで動作確認してみましょう。
まずCognitoのトークンエンドポイントからアクセストークンを取得します。
curl -X POST https://<Cognitoのドメイン>.auth.ap-northeast-1.amazoncognito.com/oauth2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=<クライアントID>&client_secret=<クライアントシークレット>"
取得したアクセストークンとゲートウェイのエンドポイントをMCP InspectorのUIから入力し、Connectをクリックします。続いてList Toolsをクリックするとツールの一覧が取得できるのでgetTVBroadcastInfoを選択してRun Toolをクリック、TV放送の履歴が取得できれば動作確認完了です。

ちなみにパラメータのbasePathに適当な値を指定すると403エラーとなります。。。

デプロイしたAPI GWのステージからOpen APIの定義をエクスポートすると分かるのですが、serversの定義が以下のようになりbasePathという変数が自動的に定義されるため、Agent CoreがbasePathもMCPツールのパラメータとして認識してしまうようです。
servers:
- url: "https://<API GWのID>.execute-api.ap-northeast-1.amazonaws.com/{basePath}"
variables:
basePath:
default: "prd"
そのためbasePathに存在しないステージ名を指定するとエラーになってしまいます。
つまりこのツールを正しく動作させるにはリクエスト時にbasePathを指定しないか、basetPathにprd(SAMテンプレートのStageNameで指定した値)を指定する必要があります。DevOps Agentからツールを呼び出す際もこの点に注意する必要があります。
DevOps AgentにMCPサーバーを追加
続いてDevOps Agent側にMCPサーバーを追加していきます。


まずEndpoint URLにはゲートウェイのURLを入力します。

今回はCognitoのClient Credentials Grant(M2M認証)を使うのでAuthorization FlowにはOAuth Client Credentialsを選択します。

Cognitoで発行したクライアントID、シークレットとトークンエンドポイントを入力します。
全て入力できたらMCPサーバーの追加完了です。


DevOps AgentにRunbookを追加
続いてDevOps AgentにRunbookを追加します。

内容は以下のように入力しました。
Title
Default Run Book
Description
Always use this Run Book
Content
One of the characteristics of this system is that spikes in access can occur due to TV broadcasts.
TV broadcast information can be obtained through the MCP server.
When using the MCP server, the parameter `basePath` must be `prd`.
このRunbookによって以下の情報をDevOps Agentに渡しています。
- TV放送によるスパイクアクセスが発生するシステムであること
- TV放送に関する情報はMCPサーバーから取得できること
- TV放送に関する情報を取得するツールを利用する際、
basePathにはprdを指定すること
DevOps Agentに調査させてみる
ここまでで下準備が整ったので擬似的にスパイクアクセスを発生させてDevOps Agentに調査させてみます。
適当なAPI GWがあったのでabコマンドで簡易的にスパイクアクセスを再現します。
ab -n 50000 -c 200 https://<API GWのエンドポイント>
abコマンドの実行完了後、対象API GWのメトリクスは以下のようになりました。スパイクアクセスっぽいメトリクスになってますね。

仕込みが終わったのでDevOps Agentにスパイクアクセスの原因調査を指示します。

しばらく待つとRunbookの指示に従ってMCPサーバーを利用してTV放送に関する情報を収集していることが分かります。

Excellent! I found highly relevant information.
The TV broadcast data shows a broadcast occurred on 2026-01-07 from 13:20-13:40 JST (04:20-04:40 UTC),
which aligns precisely with the incident time of 04:25 UTC.
Now let me gather topology and metrics data:
とのことです!ちゃんとTV放送とスパイクアクセスの関連性を分析できていますね。
このまましばらく放っておくと調査が完了しました。

Findingとして以下の調査結果を報告してくれています。※見やすいように改行など微調整しています
TV broadcast triggered 50,000x traffic surge to PetStore API
A TV broadcast featuring a celebrity introduction aired on 2026-01-07 from 13:20-13:40 JST (04:20-04:40 UTC),
directly causing a traffic surge to the PetStore API Gateway.
The API experienced 50,000 requests at 04:26:00 UTC, representing a 50,000x increase from the idle baseline (0 requests during 03:00-04:00 UTC period).
This TV broadcast traffic pattern is a documented characteristic of the system per the operational runbook.
The API Gateway MOCK integration at GET / likely handled the traffic by returning static HTML welcome pages without backend processing,
evidenced by:
(1) zero Lambda invocations,
(2) absence of integration latency metrics,
and (3) exceptional performance with p99 latency under 5ms.
The system handled this surge successfully with zero errors (0 4XX, 0 5XX) and no throttling, demonstrating the API Gateway infrastructure scaled seamlessly to handle the cold-start traffic spike.
最終的にDevOps Agentが出してきたレポート
最終的にDevOps Agentが出してきたレポートは以下の通りでした。
Impact ※見やすいように改行など微調整しています
The PetStore API Gateway (<API GWのID>) experienced a massive traffic spike from 1 request/minute baseline to 50,000 requests at 2026-01-07T04:26:00Z.
This surge coincides with a TV broadcast (13:20-13:40 JST / 04:20-04:40 UTC) featuring a celebrity introduction.
No 4XX or 5XX errors were observed during the spike.
The impact lasted approximately 15 minutes (2026-01-07T04:25:00Z - 2026-01-07T04:40:00Z).
Key findings ※見やすいように改行など微調整しています
1. TV broadcast triggered 50,000x traffic surge to PetStore API
A TV broadcast featuring a celebrity introduction aired on 2026-01-07 from 13:20-13:40 JST (04:20-04:40 UTC), directly causing a traffic surge to the PetStore API Gateway.
The API experienced 50,000 requests at 04:26:00 UTC, representing a 50,000x increase from the idle baseline (0 requests during 03:00-04:00 UTC period).
This TV broadcast traffic pattern is a documented characteristic of the system per the operational runbook.
The API Gateway MOCK integration at GET / likely handled the traffic by returning static HTML welcome pages without backend processing,
evidenced by:
(1) zero Lambda invocations,
(2) absence of integration latency metrics,
and (3) exceptional performance with p99 latency under 5ms.
The system handled this surge successfully with zero errors (0 4XX, 0 5XX) and no throttling,
demonstrating the API Gateway infrastructure scaled seamlessly to handle the cold-start traffic spike.
Investigation gaps ※見やすいように改行など微調整しています
API Gateway access logging disabled prevents detailed request analysis
The hypothesis that a specific endpoint pattern or client behavior caused issues during the traffic surge could not be validated because API Gateway access logging is not configured for the PetStore API (<API GWのID>).
Access logs would have revealed:
(1) which specific endpoints (/GET, /pets, /pets/{petId}) received the 50,000 requests,
(2) client IP addresses and user agents to identify bot vs legitimate user traffic,
(3) per-request latency to identify outliers beyond the p99 metric,
(4) any authorization failures or malformed requests that might indicate attack patterns.
The log group /aws/apigateway/welcome exists but has received no data since September 2024, and stage configuration confirms accessLogSettings is not configured.
This gap prevented definitive determination of which integration (MOCK at /, HTTP proxy at /pets, or HTTP proxy at /pets/{petId}) handled the surge, though metrics strongly suggest the MOCK integration.
要約すると以下のようになります。
- TV放送に起因したスパイクアクセスが発生したが、特に問題なく捌き切れた
- オブザーバビリティを改善するためにAPI GWのアクセスログ有効化やアラームの設定を検討すべき
妥当な内容だと思います。
まとめ
Agent Coreで自作したMCPサーバーとDevOps Agentを連携させてみました。
今回はオンコードでTV放送の情報を返却する簡易なLambdaを使って検証しましたが、実際のユースケースでは各種DBや外部APIと連携してインシデントに関連しそうな情報が取得できるとDevOps Agentがより便利に使えそうですね。こういうテクニックもうまく使って人間の作業を減らしていきたいです。








