From 16404cb843567793b10d0292b087aa1e65b27029 Mon Sep 17 00:00:00 2001 From: hideyukiMORI Date: Tue, 19 May 2026 23:05:12 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20MCP=20howto=20=E3=81=ABMCP=E3=81=A8HTTP?= =?UTF-8?q?=20API=E3=81=A7DB=E5=85=B1=E6=9C=89=E3=81=99=E3=82=8B=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E3=82=92=E8=BF=BD=E8=A8=98=20(FT3-F2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #82 Co-Authored-By: Claude Sonnet 4.6 --- docs/howto/mcp-setup.md | 31 +++++++++++++++++++++++++++++++ docs/ja/howto/mcp-setup.md | 31 +++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/docs/howto/mcp-setup.md b/docs/howto/mcp-setup.md index e072a53..24927c8 100644 --- a/docs/howto/mcp-setup.md +++ b/docs/howto/mcp-setup.md @@ -75,3 +75,34 @@ server = create_mcp_server() server.run(transport="sse") # Server-Sent Events server.run(transport="streamable-http") # HTTP streaming ``` + +--- + +## Sharing state between MCP server and HTTP API + +The MCP server runs as a **separate process** from the HTTP API. +`InMemoryXxxRepository` creates its own isolated store per process — +data written via MCP is not visible to the HTTP API, and vice versa. + +To share state, point both processes at the same persistent database: + +**HTTP API `.env`**: + +```dotenv +DB_ADAPTER=sqlite +DB_NAME=/absolute/path/to/shared.db +``` + +**Claude Desktop `claude_desktop_config.json`**: + +```json +"env": { + "DB_ADAPTER": "sqlite", + "DB_NAME": "/absolute/path/to/shared.db" +} +``` + +Both processes open the same SQLite file via SQLAlchemy. +SQLite's WAL mode handles concurrent reads safely for light workloads. + +> For high-concurrency production use, prefer MySQL or PostgreSQL. diff --git a/docs/ja/howto/mcp-setup.md b/docs/ja/howto/mcp-setup.md index 77c2d19..bfa8797 100644 --- a/docs/ja/howto/mcp-setup.md +++ b/docs/ja/howto/mcp-setup.md @@ -75,3 +75,34 @@ server = create_mcp_server() server.run(transport="sse") # Server-Sent Events server.run(transport="streamable-http") # HTTP ストリーミング ``` + +--- + +## MCP サーバーと HTTP API でデータを共有する + +MCP サーバーは HTTP API とは**別プロセス**として起動します。 +`InMemoryXxxRepository` はプロセスごとに独立したストアを持つため、 +MCP で書き込んだデータは HTTP API からは見えません(逆も同様)。 + +データを共有するには、両者が同じ永続化 DB ファイルを参照するように設定します。 + +**HTTP API の `.env`**: + +```dotenv +DB_ADAPTER=sqlite +DB_NAME=/absolute/path/to/shared.db +``` + +**Claude Desktop の `claude_desktop_config.json`**: + +```json +"env": { + "DB_ADAPTER": "sqlite", + "DB_NAME": "/absolute/path/to/shared.db" +} +``` + +両プロセスが SQLAlchemy 経由で同じ SQLite ファイルを開きます。 +SQLite の WAL モードは軽量な同時アクセスを安全に処理します。 + +> 高並列のプロダクション環境では MySQL や PostgreSQL を推奨します。