README.md

  1<!--
  2SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
  3
  4SPDX-License-Identifier: CC0-1.0
  5-->
  6
  7# sb-mcp
  8
  9[![Go Report Card](https://goreportcard.com/badge/git.secluded.site/sb-mcp)](https://goreportcard.com/report/git.secluded.site/sb-mcp)
 10[![MutuaL-1.2](https://img.shields.io/badge/License-MutuaL--1.2-af2e1a?style=flat&labelColor=110402&link=https%3A%2F%2Fcodeberg.org%2FMutualism%2FMutualist-License)](https://codeberg.org/Mutualism/Mutualist-License)
 11[![scratchanitch.dev badge](https://img.shields.io/badge/scratchanitch-dev-FFC4B5)](https://scratchanitch.dev)
 12[![REUSE status](https://api.reuse.software/badge/git.secluded.site/sb-mcp)](https://api.reuse.software/info/git.secluded.site/sb-mcp)
 13[![Liberapay donation status](https://img.shields.io/liberapay/receives/Amolith.svg?logo=liberapay)](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
 45## Tools
 46
 47| Tool           | Description                                                          |
 48| -------------- | -------------------------------------------------------------------- |
 49| `execute_lua`  | Run a Space Lua script on the SilverBullet instance.                 |
 50| `screenshot`   | Capture the current SilverBullet viewport as a PNG image.            |
 51| `console_logs` | Retrieve recent console log entries from SilverBullet for debugging. |
 52| `usage`        | Load the full SilverBullet usage guide (Space Lua syntax, APIs, gotchas). |
 53
 54### `execute_lua` parameters
 55
 56| Parameter | Type   | Description                                               |
 57| --------- | ------ | --------------------------------------------------------- |
 58| `script`  | string | The script to execute.                                    |
 59| `timeout` | int    | Maximum execution time in seconds (1–21600, default 120). |
 60
 61### `console_logs` parameters
 62
 63| Parameter | Type | Description                                                     |
 64| --------- | ---- | --------------------------------------------------------------- |
 65| `limit`   | int  | Maximum number of log entries to return (1–1000, default 100).  |
 66| `since`   | int  | Only return entries newer than this unix millisecond timestamp. |
 67
 68## Installation
 69
 70Pre-built binaries are available at
 71[releases.secluded.site/sb-mcp/latest][bin-latest].
 72
 73[bin-latest]: https://releases.secluded.site/sb-mcp/latest
 74
 75- Using [mise](https://mise.jdx.dev/) (recommended), copy the snippet from the
 76  releases page into your `mise.toml` or global `~/.config/mise/config.toml` to
 77  automate updates.
 78- Without mise, or a similar tool, download the binary for your platform from
 79  the releases page and place it somewhere in your `$PATH`.
 80
 81## Configuration
 82
 83All configuration is through environment variables and command-line flags.
 84
 85| Variable     | Required | Description                                                                |
 86| ------------ | -------- | -------------------------------------------------------------------------- |
 87| `SB_URL`     | **yes**  | Base URL of your SilverBullet instance (e.g. `https://notes.example.com`). |
 88| `SB_TOKEN`   | no       | Bearer token for `Authorization` header.                                   |
 89| `SB_USER`    | no       | Username for cookie-based session auth (used with `SB_PASS`).              |
 90| `SB_PASS`    | no       | Password for cookie-based session auth (used with `SB_USER`).              |
 91| `SB_TIMEOUT` | no       | Default Lua execution timeout in seconds (default 120).                    |
 92
 93`SB_TOKEN` and `SB_USER`/`SB_PASS` don't override each other and can be set
 94simultaneously. This is helpful if your instance is behind some kind of
 95authenticating proxy: the token can get you through the proxy and user/pass get
 96you into the instance.
 97
 98## Usage
 99
100```bash
101# stdio
102SB_URL=https://notes.example.com sb-mcp serve
103
104# http
105SB_URL=https://notes.example.com sb-mcp serve --http :3001
106```
107
108## Contributing
109
110Patch requests are in
111[amolith/llm-projects](https://pr.pico.sh/r/amolith/llm-projects) on
112[pr.pico.sh](https://pr.pico.sh). You don't need a new account to contribute,
113you don't need to fork this repo, you don't need to fiddle with `git
114send-email`, you don't need to faff with your email client to get `git
115request-pull` working...
116
117You just need:
118
119- Git
120- SSH
121- An SSH key
122
123```bash
124# Clone this repo, make your changes, and commit them
125# Create a new patch request with
126git format-patch origin/main --stdout | ssh pr.pico.sh pr create amolith/llm-projects
127# After potential feedback, submit a revision to an existing patch request with
128git format-patch origin/main --stdout | ssh pr.pico.sh pr add {prID}
129# List patch requests
130ssh pr.pico.sh pr ls amolith/llm-projects
131```
132
133See "How do Patch Requests work?" on [pr.pico.sh](https://pr.pico.sh)'s home
134page for a more complete example workflow.