Run docs-mcp as a long-lived shared HTTP service (#1)

Co-authored-by: Ajay Krishnan <ajay@krishnan.ca>
Co-committed-by: Ajay Krishnan <ajay@krishnan.ca>
This commit was merged in pull request #1.
This commit is contained in:
2026-05-24 15:48:24 +00:00
committed by Ajay Krishnan
parent f7ab811d93
commit 6629a9b284
10 changed files with 210 additions and 63 deletions

View File

@@ -14,29 +14,34 @@ shell code.
| `CONTEXT_KIT_DATA_DIR` | `$HOME/.local/share/context-kit` | Persistent docs indexes and model cache |
| `CONTEXT_KIT_COMPOSE_PROJECT` | `context-kit` | Docker Compose project and network prefix |
| `CONTEXT_KIT_SEARXNG_PORT` | `8099` | Localhost SearXNG port |
| `CONTEXT_KIT_DOCS_TTL` | `7d` | Docs re-fetch cadence |
| `CONTEXT_KIT_DOCS_PORT` | `8776` | Localhost port for the long-lived docs-mcp HTTP service |
| `CONTEXT_KIT_DOCS_HTTP_URL` | `http://127.0.0.1:${CONTEXT_KIT_DOCS_PORT}/mcp` | URL emitted into install snippets and used by the stdio bridge |
| `CONTEXT_KIT_DOCS_TTL` | `24h` | Docs re-fetch cadence |
| `CONTEXT_KIT_DOCS_SOURCES` | `config/sources.default.txt` | Space-separated source profile files |
| `CONTEXT_KIT_DOCS_MAX_GET_BYTES` | `75000` | Max bytes returned by docs retrieval |
| `CONTEXT_KIT_DOCS_EMBED_MODEL` | `BAAI/bge-small-en-v1.5` | SentenceTransformers embedding model |
| `CONTEXT_KIT_DOCS_PREINDEX` | `0` | Set to `1` to re-embed every source on container start |
## TTL Guidance
`7d` is the default because most reference docs do not need daily re-embedding.
`24h` is the default. Most reference docs do not need re-embedding more often,
and the shared service does not re-fetch sources until the TTL elapses.
Use shorter TTLs for fast-moving APIs:
```sh
CONTEXT_KIT_DOCS_TTL=72h bin/context-kit docs
CONTEXT_KIT_DOCS_TTL=6h bin/context-kit restart
```
Use longer TTLs for stable specs:
```sh
CONTEXT_KIT_DOCS_TTL=30d bin/context-kit docs
CONTEXT_KIT_DOCS_TTL=30d bin/context-kit restart
```
When freshness matters for one task, prefer a manual refresh through the docs
MCP tool instead of lowering the global TTL for every session.
The docs-mcp container reads `CONTEXT_KIT_DOCS_TTL` at startup, so changes
require `bin/context-kit restart`. When freshness matters for one task, prefer
calling the `docs_refresh` MCP tool instead of lowering the global TTL.
## Source Profiles