API keys & MCP (the mcpserver-link prerequisite from STRATEGY.md): - ApiKey table (migration 017 + schema.sql): hash-only storage of personal "sb_..." Bearer credentials, unique keyHash, owner cascade. - internal/auth/apikeys.go + AuthMiddleware fork: keys resolve before the assertion/cookie channels; gated on the mcp-core connector at issuance AND at every use (downgrade 403s); independent of tokenVersion so "sign out everywhere" never breaks a gateway link; view-as stays browser-only. - /api/keys GET/POST/DELETE: plaintext shown exactly once, 10-key cap under the user lock, owner-scoped revocation; Settings -> API Keys tab. - mcp/: superbrain-mcp, a pip-installable stdio MCP server (listmonk-mcp pattern) with bookmarks/tags/pages tools, version-safe updates; the federated gateway spawns it via config_mcpserver_superbrain() in deploy/federated/lib-superbrain.sh (mints the gateway key in-db, points it at http://superbrain-app:8080). STRATEGY.md records the remaining suite-side registry work. - Tests: TestAPIKeys (plan gate, cap, revocation, tokenVersion semantics, downgrade-at-use); full DB-backed suite, db-converge, live MCP-client smoke all pass. Markdown (Gitea issue #3): add @tailwindcss/typography and enable it in tailwind.config.ts. The prose wrapper was a no-op without it, so Tailwind Preflight flattened headings/blockquotes to body text while bold/italic survived - exactly the reported symptom. Verified in the built CSS. Gitea: #2 and #3 closed with reference notes; #1 stays open pending the Superpanel core-AI walkthrough.
74 lines
2.6 KiB
Markdown
74 lines
2.6 KiB
Markdown
# superbrain-mcp
|
|
|
|
MCP (Model Context Protocol) server for Superbrain — exposes bookmarks,
|
|
tags and Markdown pages to AI tools over the Superbrain REST API. Same
|
|
shape as the other federated-suite MCP servers (e.g. `listmonk-mcp`): a
|
|
pip-installable stdio server configured entirely by environment variables.
|
|
|
|
## Run
|
|
|
|
```sh
|
|
pip install ./mcp # or: pipx install ./mcp
|
|
export SUPERBRAIN_API_URL=http://localhost:8080 # the Go API, directly
|
|
export SUPERBRAIN_API_KEY=sb_... # Settings → API Keys
|
|
superbrain-mcp
|
|
```
|
|
|
|
`SUPERBRAIN_API_URL` must point at the **Go API**, not the web UI: the
|
|
Next.js proxy signs browser assertions and never forwards a Bearer key.
|
|
On a federated core the gateway uses `http://superbrain-app:8080`
|
|
(container-name DNS on the `core` network).
|
|
|
|
API keys require the tenant's plan to include the `mcp-core` connector
|
|
(core plan). Keys are issued in the web UI (Settings → API Keys) or, for
|
|
suite automation, by `config_mcpserver_superbrain()` in
|
|
`deploy/federated/lib-superbrain.sh`.
|
|
|
|
## MCP client config (e.g. Claude Desktop/Code)
|
|
|
|
```json
|
|
{
|
|
"mcpServers": {
|
|
"superbrain": {
|
|
"command": "superbrain-mcp",
|
|
"env": {
|
|
"SUPERBRAIN_API_URL": "https://superbrain.example.tld:8080",
|
|
"SUPERBRAIN_API_KEY": "sb_..."
|
|
}
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## Tools
|
|
|
|
| Tool | Description |
|
|
|---|---|
|
|
| `search_bookmarks` | free-text + tag filter over bookmarks |
|
|
| `get_bookmark` / `get_bookmark_markdown` | one bookmark (JSON / Markdown) |
|
|
| `create_bookmark` | save a link with title/notes/due date/tags (missing tags are created) |
|
|
| `update_bookmark` | partial update under the `version` contract; `""` clears nullable fields |
|
|
| `delete_bookmark` | move to Trash |
|
|
| `list_tags` / `create_tag` | tag inventory |
|
|
| `list_pages` / `get_page` / `get_page_markdown` | page inventory and bodies |
|
|
| `create_page` / `update_page` / `append_to_page` | write Markdown pages (version-safe read-modify-write) |
|
|
|
|
Concurrent-edit conflicts surface as tool errors mentioning 409 — re-read
|
|
and retry.
|
|
|
|
## Federated mcpserver gateway
|
|
|
|
The suite gateway (`federatedcomputer/mcpserver`) spawns this package when
|
|
its `.env` carries `SUPERBRAIN_API_URL` (the registry entry in its
|
|
`apps_registry.py` is `"superbrain": {required_env: "SUPERBRAIN_API_URL",
|
|
command: "superbrain-mcp", args: []}`). Linking on a core host:
|
|
|
|
```sh
|
|
/federated/bin/installapp-mcpserver superbrain
|
|
```
|
|
|
|
which runs `config_mcpserver_superbrain()` (mints a dedicated `mcpserver`
|
|
key for the admin account, directly in the database — the house pattern
|
|
for apps whose credential creation is not a public API) and restarts the
|
|
gateway so `mcphub` and Hermes pick the tools up.
|