Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions docs/howto/mcp-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
31 changes: 31 additions & 0 deletions docs/ja/howto/mcp-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 を推奨します。
Loading