Files
registry_mcp/README.md
T
2026-05-09 13:29:32 +02:00

89 lines
2.6 KiB
Markdown

# registry_mcp
Servidor MCP que expone `registry.db` a Claude (Code, Desktop, otros clientes MCP).
## Tools
| Tool | Args | Returns |
|---|---|---|
| `fn_search` | `query, kind?, lang?, domain?, purity?, limit?` | `{ results: [{id,name,kind,lang,domain,purity,signature,description}] }` |
| `fn_show` | `id` | `{ id, markdown }` |
| `fn_code` | `id` | `{ id, lang, code }` |
| `fn_list_domains` | — | `{ domains: [{domain,functions,types,pure,impure,by_lang}] }` |
| `fn_uses` | `id` | `{ uses_functions, uses_types, consumed_by }` |
| `fn_doctor` | `subcommand?` | `{ report }` |
| `fn_run` | `id, args?` | `{ stdout, stderr, exit_code }` (require `--enable-run`) |
| `fn_create_function` | `name, lang, domain, signature, description, purity, code, md_body?` | `{ id, file_paths }` (require `--enable-write`) |
## Build
```bash
CGO_ENABLED=1 go build -tags fts5 -o registry_mcp .
```
## Run
```bash
# stdio (default)
./registry_mcp
# stdio + write tools enabled
./registry_mcp --enable-run --enable-write
# HTTP loopback
./registry_mcp --http :7733
REGISTRY_API_TOKEN=xxx ./registry_mcp --http :7733 --bind 0.0.0.0
```
## Instalar en Claude Code
Crear `.mcp.json` en la raiz del proyecto donde se invoque `claude`:
```json
{
"mcpServers": {
"registry": {
"command": "/abs/path/fn_registry/apps/registry_mcp/registry_mcp",
"args": ["--enable-run", "--enable-write"],
"env": { "FN_REGISTRY_ROOT": "/abs/path/fn_registry" }
}
}
}
```
O usar `make install-claude-code` que escribe la entrada al `.mcp.json` del cwd.
## Instalar en Claude Desktop
Editar `~/.config/Claude/claude_desktop_config.json` (Linux) o
`~/Library/Application Support/Claude/claude_desktop_config.json` (macOS):
```json
{
"mcpServers": {
"registry": {
"command": "/abs/path/registry_mcp",
"env": { "FN_REGISTRY_ROOT": "/abs/path/fn_registry" }
}
}
}
```
## Ejemplos de queries
Sesion Claude:
- "busca funciones puras de finance" → `fn_search({query: "finance", purity: "pure"})`
- "muestra el codigo de filter_slice_go_core" → `fn_show({id: "filter_slice_go_core"})`
- "que funciones usan sqlite_open_go_infra" → `fn_uses({id: "sqlite_open_go_infra"})`
- "diagnostico" → `fn_doctor({})`
- "ejecuta backup_all_bash_pipelines a /tmp" → `fn_run({id: "backup_all_bash_pipelines", args: ["/tmp"]})`
## Variables de entorno
| Var | Default | Para que |
|---|---|---|
| `FN_REGISTRY_ROOT` | autodetect via `go.mod` upward | Raiz del repo (donde vive `registry.db`) |
| `REGISTRY_API_TOKEN` | (vacio) | Obligatorio para HTTP en interfaces no-loopback |
| `FN_BIN` | `fn` (PATH) | Binario `fn` para subprocess `fn_run`/`fn_doctor` |