1<!--
2SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
3
4SPDX-License-Identifier: CC0-1.0
5-->
6
7# sb-mcp
8
9[](https://goreportcard.com/report/git.secluded.site/sb-mcp)
10[](https://codeberg.org/Mutualism/Mutualist-License)
11[](https://scratchanitch.dev)
12[](https://api.reuse.software/info/git.secluded.site/sb-mcp)
13[](https://liberapay.com/Amolith/)
14
15_Four-tool MCP server for [SilverBullet]_
16
17[SilverBullet]: https://silverbullet.md
18
19## Contents
20
21- [Why?](#why)
22- [Tools](#tools)
23- [Installation](#installation)
24- [Configuration](#configuration)
25- [Usage](#usage)
26- [Contributing](#contributing)
27
28## Why?
29
30SilverBullet is a note-taking/knowledge-management tool with a powerful Runtime
31API that can execute [Space Lua], take screenshots, and surface console logs.
32
33sb-mcp wraps the Runtime API in a [Model Context Protocol] server so coding
34agents can read and write notes, run queries, debug plug failures, and generally
35treat your SilverBullet space as a first-class workspace.
36
37[Space Lua]: https://silverbullet.md/Space%20Lua
38[Model Context Protocol]: https://modelcontextprotocol.io
39
40Because I always want to know, the prose your agent would receive if it
41calls the `usage` tool is
42
43- [internal/server/silverbullet.md](https://git.secluded.site/sb-mcp/blob/main/internal/server/silverbullet.md)
44- [internal/server/tools.go](https://git.secluded.site/sb-mcp/blob/main/internal/server/tools.go)
45
46## Tools
47
48| Tool | Description |
49| -------------- | -------------------------------------------------------------------- |
50| `execute_lua` | Run a Space Lua script on the SilverBullet instance. |
51| `screenshot` | Capture the current SilverBullet viewport as a PNG image. |
52| `console_logs` | Retrieve recent console log entries from SilverBullet for debugging. |
53| `usage` | Load the full SilverBullet usage guide (Space Lua syntax, APIs, gotchas). |
54
55### `execute_lua` parameters
56
57| Parameter | Type | Description |
58| --------- | ------ | --------------------------------------------------------- |
59| `script` | string | The script to execute. |
60| `timeout` | int | Maximum execution time in seconds (1–21600, default 120). |
61
62### `console_logs` parameters
63
64| Parameter | Type | Description |
65| --------- | ---- | --------------------------------------------------------------- |
66| `limit` | int | Maximum number of log entries to return (1–1000, default 100). |
67| `since` | int | Only return entries newer than this unix millisecond timestamp. |
68
69## Installation
70
71Pre-built binaries are available at
72[releases.secluded.site/sb-mcp/latest][bin-latest].
73
74[bin-latest]: https://releases.secluded.site/sb-mcp/latest
75
76- Using [mise](https://mise.jdx.dev/) (recommended), copy the snippet from the
77 releases page into your `mise.toml` or global `~/.config/mise/config.toml` to
78 automate updates.
79- Without mise, or a similar tool, download the binary for your platform from
80 the releases page and place it somewhere in your `$PATH`.
81
82## Configuration
83
84All configuration is through environment variables and command-line flags.
85
86| Variable | Required | Description |
87| ------------ | -------- | -------------------------------------------------------------------------- |
88| `SB_URL` | **yes** | Base URL of your SilverBullet instance (e.g. `https://notes.example.com`). |
89| `SB_TOKEN` | no | Bearer token for `Authorization` header. |
90| `SB_USER` | no | Username for cookie-based session auth (used with `SB_PASS`). |
91| `SB_PASS` | no | Password for cookie-based session auth (used with `SB_USER`). |
92| `SB_TIMEOUT` | no | Default Lua execution timeout in seconds (default 120). |
93
94`SB_TOKEN` and `SB_USER`/`SB_PASS` don't override each other and can be set
95simultaneously. This is helpful if your instance is behind some kind of
96authenticating proxy: the token can get you through the proxy and user/pass get
97you into the instance.
98
99## Usage
100
101```bash
102# stdio
103SB_URL=https://notes.example.com sb-mcp serve
104
105# http
106SB_URL=https://notes.example.com sb-mcp serve --http :3001
107```
108
109## Contributing
110
111Patch requests are in
112[amolith/llm-projects](https://pr.pico.sh/r/amolith/llm-projects) on
113[pr.pico.sh](https://pr.pico.sh). You don't need a new account to contribute,
114you don't need to fork this repo, you don't need to fiddle with `git
115send-email`, you don't need to faff with your email client to get `git
116request-pull` working...
117
118You just need:
119
120- Git
121- SSH
122- An SSH key
123
124```bash
125# Clone this repo, make your changes, and commit them
126# Create a new patch request with
127git format-patch origin/main --stdout | ssh pr.pico.sh pr create amolith/llm-projects
128# After potential feedback, submit a revision to an existing patch request with
129git format-patch origin/main --stdout | ssh pr.pico.sh pr add {prID}
130# List patch requests
131ssh pr.pico.sh pr ls amolith/llm-projects
132```
133
134See "How do Patch Requests work?" on [pr.pico.sh](https://pr.pico.sh)'s home
135page for a more complete example workflow.