Skip to content

Commit 7b95838

Browse files
tbrandtbrandaws
andauthored
MCP Chat (#1125)
Co-authored-by: Taichiro Suzuki <[email protected]>
1 parent da4e701 commit 7b95838

38 files changed

+2251
-32
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,12 @@ When using Knowledge Base, advanced RAG features such as [Advanced Parsing](docs
9999
Knowledge Base also allows for [Metadata Filter Settings](docs/en/DEPLOY_OPTION.md#metadata-filter-configuration).
100100
For example, you can meet requirements such as "switching accessible data sources by organization" or "allowing users to set filters from the UI."
101101

102+
Additionally, it is possible to build a RAG that references data outside of AWS by [enabling MCP chat](docs/en/DEPLOY_OPTION.md#enabling-mcp-chat-use-case) and adding an external service's MCP server to [packages/cdk/mcp-api/mcp.json](/packages/cdk/mcp-api/mcp.json).
103+
102104
</details>
103105

104106
<details markdown="1">
105-
<summary><strong><ins>I want to use custom AI agents or Bedrock Flows within my organization</ins></strong></summary>
107+
<summary><strong><ins>I want to use custom Bedrock Agents or Bedrock Flows within my organization</ins></strong></summary>
106108

107109
When you [enable agents](docs/en/DEPLOY_OPTION.md#enabling-agent-chat-use-case) in GenU, Web Search Agent and Code Interpreter Agent are created.
108110
The Web Search Agent searches the web for information to answer user questions. For example, it can answer "What is AWS GenU?"
@@ -116,6 +118,8 @@ Additionally, you can [hide unnecessary standard use cases](docs/en/DEPLOY_OPTIO
116118

117119
Similarly, there is an [import feature](docs/en/DEPLOY_OPTION.md#enabling-flow-chat-use-case) for Bedrock Flows, so please make use of it.
118120

121+
Additionally, you can create agents that perform actions on services outside AWS by [enabling MCP chat](docs/en/DEPLOY_OPTION.md#enabling-mcp-chat-use-case) and adding external MCP servers to [packages/cdk/mcp-api/mcp.json](/packages/cdk/mcp-api/mcp.json).
122+
119123
</details>
120124

121125
<details markdown="1">

README_ja.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ Knowledge Base を利用する場合は、[Advanced Parsing](docs/ja/DEPLOY_OPTI
9797
また Knowledge Base では、[メタデータフィルターの設定](docs/ja/DEPLOY_OPTION.md#メタデータフィルターの設定) も可能です。
9898
例えば「組織ごとにアクセス可能なデータソースを切り替えたい」や「UI からユーザーがフィルタを設定したい」といった要件を満たすことが可能です。
9999

100+
また、[MCP チャットを有効化](docs/ja/DEPLOY_OPTION.md#mcp-チャットユースケースの有効化) して外部サービスの MCP サーバーを [packages/cdk/mcp-api/mcp.json](/packages/cdk/mcp-api/mcp.json) に追加することで、AWS 外のデータを参照する RAG を構築することも可能です。
101+
100102
</details>
101103

102104
<details markdown="1">
103-
<summary><strong><ins>独自に作成した AI エージェントや Bedrock Flows などを社内で利用したい</ins></strong></summary>
105+
<summary><strong><ins>独自に作成した Bedrock Agents や Bedrock Flows などを社内で利用したい</ins></strong></summary>
104106

105107
GenU で [エージェントを有効化](docs/ja/DEPLOY_OPTION.md#agent-チャットユースケースの有効化)すると Web 検索エージェントと Code Interpreter エージェントが作成されます。
106108
Web 検索エージェントは、ユーザーの質問に回答するための情報を Web で検索し、回答します。例えば「AWS の GenU ってなに?」という質問に回答できます。
@@ -114,6 +116,8 @@ GenU をエージェント活用のプラットフォームとして利用する
114116

115117
Bedrock Flows に関しても同様に [インポート機能](docs/ja/DEPLOY_OPTION.md#flow-チャットユースケースの有効化) がございますので、ぜひご活用ください。
116118

119+
また、[MCP チャットを有効化](docs/ja/DEPLOY_OPTION.md#mcp-チャットユースケースの有効化) して外部サービスの MCP サーバーを [packages/cdk/mcp-api/mcp.json](/packages/cdk/mcp-api/mcp.json) に追加することで、AWS 外のサービスにも何らかのアクションを起こすエージェントを作成することも可能です。
120+
117121
</details>
118122

119123
<details markdown="1">

docs/en/DEPLOY_OPTION.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,60 @@ const envs: Record<string, Partial<StackInput>> = {
562562
}
563563
```
564564

565+
### Enabling MCP Chat Use Case
566+
567+
[MCP (Model Context Protocol)](https://modelcontextprotocol.io/introduction) is a protocol that connects LLM models with external data and tools.
568+
In GenU, we provide chat use cases that execute MCP-compliant tools using [Strands Agents](https://strandsagents.com/latest/).
569+
To enable MCP chat use cases, the `docker` command must be executable.
570+
571+
**Edit [parameter.ts](/packages/cdk/parameter.ts)**
572+
573+
```
574+
const envs: Record<string, Partial<StackInput>> = {
575+
dev: {
576+
mcpEnabled: true,
577+
},
578+
};
579+
```
580+
581+
**Edit [packages/cdk/cdk.json](/packages/cdk/cdk.json)**
582+
583+
```json
584+
// cdk.json
585+
{
586+
"context": {
587+
"mcpEnabled": true
588+
}
589+
}
590+
```
591+
592+
The MCP servers to be used are defined in [packages/cdk/mcp-api/mcp.json](/packages/cdk/mcp-api/mcp.json).
593+
If you want to add tools other than those defined by default, please modify mcp.json.
594+
595+
**However, there are currently the following constraints on the MCP server and its configuration:**
596+
597+
- The MCP server runs on AWS Lambda, so file writing is not possible. (Writing to `/tmp` is possible, but you cannot retrieve the files.)
598+
- The MCP server must be executable with `uvx` or `npx`.
599+
- The MCP client can only use stdio.
600+
- Currently, multimodal requests are not supported.
601+
- A mechanism to dynamically obtain API Keys and set them as environment variables has not yet been implemented.
602+
- A mechanism for users to select which MCP server to use has not yet been implemented. (Currently, all tools defined in mcp.json are used.)
603+
- In mcp.json, you can configure `command`, `args`, and `env`. Here's a specific example:
604+
605+
```json
606+
{
607+
"mcpServers": {
608+
"SERVER_NAME": {
609+
"command": "uvx",
610+
"args": ["SERVER_ARG"]
611+
"env": {
612+
"YOUR_API_KEY": "xxx"
613+
}
614+
}
615+
}
616+
}
617+
```
618+
565619
### Enabling Flow Chat Use Case
566620

567621
In the Flow Chat use case, you can call created Flows.

docs/ja/DEPLOY_OPTION.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,60 @@ const envs: Record<string, Partial<StackInput>> = {
577577
}
578578
```
579579

580+
### MCP チャットユースケースの有効化
581+
582+
[MCP (Model Context Protocol)](https://modelcontextprotocol.io/introduction) とは、LLM モデルと外部データやツールを繋ぐプロトコルです。
583+
GenU では [Strands Agents](https://strandsagents.com/latest/) を活用して MCP に準拠したツールを実行するチャットユースケースを用意しています。
584+
MCP チャットユースケースを有効化するためには、`docker` コマンドが実行可能である必要があります。
585+
586+
**[parameter.ts](/packages/cdk/parameter.ts) を編集**
587+
588+
```
589+
const envs: Record<string, Partial<StackInput>> = {
590+
dev: {
591+
mcpEnabled: true,
592+
},
593+
};
594+
```
595+
596+
**[packages/cdk/cdk.json](/packages/cdk/cdk.json) を編集**
597+
598+
```json
599+
// cdk.json
600+
{
601+
"context": {
602+
"mcpEnabled": true
603+
}
604+
}
605+
```
606+
607+
利用する MCP サーバーは [packages/cdk/mcp-api/mcp.json](/packages/cdk/mcp-api/mcp.json) に定義されております。
608+
デフォルトで定義されているツール以外のツールを累加する場合は、mcp.json を変更してください。
609+
610+
**ただし、現状 MCP サーバーとその設定には以下の制約があります。**
611+
612+
- MCP サーバーは AWS Lambda で実行されるため、ファイルの書き込みはできません。(`/tmp` 以下に書き込むことは可能ですが、取り出すことができません。)
613+
- MCP サーバーは `uvx` または `npx` で実行可能である必要があります。
614+
- MCP クライアントは stdio のみが利用できます。
615+
- 現状、マルチモーダルのリクエストはサポートされていません。
616+
- API Key などを動的に取得して環境変数に設定する仕組みはまだ実装されていません。
617+
- ユーザーが利用する MCP サーバーを選択する仕組みはまだ実装されていません。(現状は mcp.json に定義されたすべてのツールが利用されます。)
618+
- mcp.json には `command`, `args`, `env` が設定できます。具体例は以下です。
619+
620+
```json
621+
{
622+
"mcpServers": {
623+
"SERVER_NAME": {
624+
"command": "uvx",
625+
"args": ["SERVER_ARG"]
626+
"env": {
627+
"YOUR_API_KEY": "xxx"
628+
}
629+
}
630+
}
631+
}
632+
```
633+
580634
### Flow チャットユースケースの有効化
581635

582636
Flow チャットユースケースでは、作成済みの Flow を呼び出すことができます。

0 commit comments

Comments
 (0)