MCP Server is unstable when deployed to AWS AgentCore
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
調査の方向性
src/ModelContextProtocol.AspNetCore/StreamableHttpHandler.cs の 89 行目付近から始め、AWS AgentCore のデプロイメントを通じて不正で途中で切り詰められた JSON-RPC ペイロードを再現します。リクエストボディがどのように読み取られ、JsonException がどのように WriteJsonRpcErrorAsync に到達するかを追跡します。AgentCore リクエストが確実に処理され、パース失敗時にステータス 400 だけを返すのではなく、利用可能なエラー詳細が示されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
MCP deployed to AgentCore responds with Error 400 for every jsonrpc request.
The AWS Logs did not show anything more than the status code, but I did dig out that its scenario from this Path:
https://github.com/modelcontextprotocol/csharp-sdk/blob/609499b2988e3f4a4c732552290bc9241fb90db9/src/ModelContextProtocol.AspNetCore/StreamableHttpHandler.cs#L89
To Reproduce
Steps to reproduce the behavior:
- Prepare any hello-world MCP Server and deploy it to AWS AgentCore
- Make sure it listens at /mcp on port 8000
- Try to test the MCP using AgentCore Playground (it allows you to send the json compliant with the JsonRpcMessage class)
- Response with error 400 is being returned
Expected behavior
- MCP should work in AgentCore, just like Python FastMCP
WriteJsonRpcErrorAsyncshould expose what exactly went wrong with parsing the json-rpc. The data is present inJsonExceptionbut is not used.
Logs
Additional context
- I tried to solve the issue on my own by preparing custom
StreamableHttpHandlerand printing what it sees. This way I learned that it sees malformed payloads, JSON documents cut in half.
Then I tried to get away with Middleware like this to mitigate the issue:
app.Use(async(context, next) => {
context.Request.EnableBuffering();
ResetStream(context);
await next();
ResetStream(context);
};
// ...
static void ResetStream(HttpContext context) {
if (context.Request.Body.CanSeek) context.Request.Body.Position = 0;
}
After doing this, I'm able to send the request in the AWS AgentCore Tester UI, but only once, after that I need to refresh the page, so there is still something missing.
- In AgentCore, MCP Servers are not accessible directly, instead there's AWS AgentCore API to be used, and some other entity inside AWS infrastructure is sending the requests to target MCP.
- 主要言語
- C#
- スター
- 4.5k
- フォーク
- 814
- 平均マージ
- 9日 19時間
- マージ済み PR(30日)
- 4
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelcontextprotocol/csharp-sdk のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
modelcontextprotocol/csharp-sdk#1867 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
modelcontextprotocol/csharp-sdk#1840 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
modelcontextprotocol/csharp-sdk#1836 ·
-
enhancement needs confirmation
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
modelcontextprotocol/csharp-sdk#678 · コメント 1 件 ·
-
enhancement needs confirmation P3 ready for work
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
modelcontextprotocol/csharp-sdk#515 · コメント 6 件 · リアクション 3 件 ·
modelcontextprotocol/csharp-sdk の issue をすべて見る
似ている issue
-
type/automation type/tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
t/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
ci-failure-cause test-failure
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
area:auth FE mvp P3
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
klasolsson81/jobbliggaren#1788 ·