yunohost-mcp
Secure MCP server for YunoHost: Nostr-authenticated, policy-controlled, auditable administration, diagnostics, and _ynh package development for AI clients (Codex, Claude, OpenCode, ChatGPT-compatible MCP clients).
See PLAN.md for the full design and phased roadmap, and PHASE0_INVESTIGATION.md for how it maps onto YunoHost's actual Python API.
Running the server
yunohost-mcp --transport stdio # local development, fully trusted (no NIP-98 handshake)
yunohost-mcp --transport http --host 127.0.0.1 --port 8765 # NIP-98-authenticated, remote-capable
By default fake_yunohost is off (real mode) — set YUNOHOST_MCP_FAKE_YUNOHOST=true to run against canned data on a machine without YunoHost installed. See identity.example.toml for identity.toml's shape (pubkey → role mapping; required before any HTTP request can do anything).
Optional local Polypack memory
The server can act as an authenticated façade for a separately installed
Polypack MCP service. Set YUNOHOST_MCP_POLYPACK_URL to that service's
loopback /mcp/ endpoint; the URL must resolve to 127.0.0.1, ::1, or
localhost, and Polypack remains the sole owner of its database. The YunoHost
MCP HTTP endpoint is still the only endpoint agents should expose publicly.
The initial integration exposes bounded memory_get, memory_list_contexts,
memory_recall, memory_context, memory_thread, memory_store, and
memory_feedback tools. Memory reads, writes, and feedback have separate
memory.read, memory.write, and memory.feedback scopes; writes are locked
and audited, while content is represented in the audit log only by length and
hash. Provenance is added by this server, and user metadata cannot forge its
reserved _yunohost_* fields. The integration is optional and core YunoHost
tools continue to work when Polypack is not installed or not configured.
Installing the client tools
The recommended client-side path is uvx, which creates an isolated
environment for the command without requiring users to manage a Python virtual
environment:
uvx --from yunohost-mcp-connect yunohost-mcp-connect --help
For a persistent command-line installation, use:
uv tool install yunohost-mcp-connect
The package is also installable with python3 -m pip install yunohost-mcp-connect; that path is mainly useful for development or systems
where uv is not available.
Agent-assisted setup
The setup wizard is designed to be run by an AI agent on the user's local machine. It generates a fresh client identity, writes the selected MCP client configuration, and prints the one remaining security-sensitive step: granting the generated npub an appropriate role on the YunoHost server.
uvx --from yunohost-mcp-connect yunohost-mcp-connect setup \
--server https://your-yunohost-domain/mcp \
--client codex \
--format json
Supported clients are codex, claude-desktop, claude-code, gemini,
hermes, and opencode.
Setup is safe to rerun, refuses conflicting server definitions, backs up an
existing configuration before changing it, and never prints the private key.
Use --print-only when the agent should display configuration without writing
it. After granting the npub and restarting the client, diagnose the connection:
uvx --from yunohost-mcp-connect yunohost-mcp-connect doctor \
--server https://your-yunohost-domain/mcp \
--key-file ~/.config/yunohost-mcp/codex.key \
--format json
Connecting a client: yunohost-mcp-connect
Mainstream MCP clients (Claude Desktop, a plain Codex install, etc.) have no way to sign a NIP-98 Authorization header — that's specific to this server. yunohost-mcp-connect bridges the gap: a small local process that speaks plain MCP over stdio to your actual client, and forwards every request to the remote --transport http server, signed with your own Nostr key.
yunohost-mcp-connect --remote-url https://your-yunohost-domain/mcp --key-file ~/.config/yunohost-mcp/key
--key-file(or$YUNOHOST_MCP_CLIENT_KEY_FILE) points at a file holding a hex ornsec1...private key — preferred over--key/$YUNOHOST_MCP_CLIENT_KEY, which put the key in argv/environment where other processes on the same machine can read it.--generate-key PATHwrites a fresh private key toPATH(0600; refuses to overwrite an existing file), prints its npub, and exits without connecting anywhere — the way to get a--key-filein the first place. Use a distinctPATHper client; see "Give each client its own key file" below.--delegation-file(or$YUNOHOST_MCP_CLIENT_DELEGATION_FILE) presents a delegation event (PLAN.md Phase 11) alongside your own signature, for a disposable agent identity an owner granted a subset of their access to.- Point your MCP client's config at this command (not the server directly) —
tools/list,tools/call,resources/list, andresources/readare forwarded verbatim; authorization, policy, and audit still happen on the remote server.
Each connector starts its local MCP endpoint independently of the remote YunoHost handshake. If one configured YunoHost instance is offline, that connector stays alive, reports no discovered tools until the instance returns, and retries on later requests; other configured MCP servers can still start and remain usable.
Incident introspection
The server includes bounded, read-only diagnostics for intermittent outages:
- web_logs parses Nginx access/error logs, including HTTP and upstream status.
- journal_query reads allowlisted service, SSH, firewall, kernel, OOM, and systemd journals.
- system_snapshot, service_history, ssh_diagnose, and network_snapshot expose host, restart, access-control, and socket state.
- http_probe tests an HTTP(S) endpoint, while incident_snapshot collects the main evidence for a time window.
Log paths, output limits, command timeouts, and whether private HTTP targets are permitted are configurable with YUNOHOST_MCP_* settings. All of these tools are read-only and enforce bounded output.
Connecting Claude Desktop or Codex
Both point at yunohost-mcp-connect, not at the server directly — the bridge is what signs each request with your Nostr key. Use the full path to yunohost-mcp-connect in whatever environment you installed yunohost-mcp into (e.g. ~/.local/pipx/venvs/yunohost-mcp/bin/yunohost-mcp-connect, or a venv's bin/ directory — which yunohost-mcp-connect after activating it will tell you).
Give each client its own key file. YUNOHOST_MCP_CLIENT_KEY_FILE is the identity — whichever key signs a request determines its role and scopes on the server, nothing else. Point two different clients (or two different config files for the same client — a project-local .codex/config.toml shadows ~/.codex/config.toml) at the same key file and the second one silently authenticates as the first, with its exact permissions - no error, nothing to notice. Generate a fresh key per client rather than copying one that already works:
yunohost-mcp-connect --generate-key ~/.config/yunohost-mcp/claude-desktop.key
yunohost-mcp-connect --generate-key ~/.config/yunohost-mcp/codex.key
Each prints the new key's npub - grant it whatever role is appropriate for that specific client (see "Granting a disposable agent identity access" below, or identity.toml directly), not the role you already gave a different one. --generate-key refuses to overwrite a file that already exists.
Claude Desktop (claude_desktop_config.json — Settings → Developer → Edit Config):
{
"mcpServers": {
"yunohost-mcp": {
"command": "/full/path/to/yunohost-mcp-connect",
"env": {
"YUNOHOST_MCP_CLIENT_REMOTE_URL": "https://your-yunohost-domain/mcp",
"YUNOHOST_MCP_CLIENT_KEY_FILE": "/home/you/.config/yunohost-mcp/claude-desktop.key"
}
}
}
}
Codex CLI (~/.codex/config.toml):
[mcp_servers.yunohost-mcp]
command = "/full/path/to/yunohost-mcp-connect"
[mcp_servers.yunohost-mcp.env]
YUNOHOST_MCP_CLIENT_REMOTE_URL = "https://your-yunohost-domain/mcp"
YUNOHOST_MCP_CLIENT_KEY_FILE = "/home/you/.config/yunohost-mcp/codex.key"
Run yunohost-mcp-connect --key-file <path> once per new key to see its npub (yunohost-mcp-connect: signing as npub1...), then grant that npub whatever role is actually appropriate for that client in identity.toml - not the role you already gave a different one.
For a delegated (disposable) identity instead of your own key, add YUNOHOST_MCP_CLIENT_DELEGATION_FILE pointing at the file yunohost-mcp-delegate produced (see below). Restart the client after editing its config — both read this file once, at startup.
Granting a disposable agent identity access: yunohost-mcp-delegate
An identity.toml entry grants access to one specific pubkey, permanently (until edited). A delegation (PLAN.md Phase 11) is the other way to grant access: an owner signs a short-lived, scoped grant to an agent's own disposable key, without ever adding that key to identity.toml or handing over any private key. yunohost-mcp-delegate is what an owner runs to create one:
yunohost-mcp-delegate --key-file ~/.config/yunohost-mcp/key \
--delegate npub1... \
--remote-url https://your-yunohost-domain/mcp \
--role readonly --ttl 24h \
--out agent-delegation.json
--delegateis the agent's own pubkey (it must sign its own NIP-98 requests as always — a delegation never replaces that, it only adds standing).--remote-urlfetches the server's pubkey and this owner's own current scopes automatically — no need to type the server's pubkey by hand, and an over-broad--scope/--rolerequest is flagged (the server can never grant more than the delegator's own current scopes; seeauth/delegation.py). Pass--serverinstead if you'd rather supply the server's pubkey directly.--scope/--role(repeatable, combinable) choose what to grant;--ttl(e.g.24h,7d) how long — the server rejects anything over 30 days.- The output is a signed delegation event: a bearer credential once issued. Hand the file to the agent to use with
yunohost-mcp-connect --delegation-file agent-delegation.json, over a channel you trust (the same as you'd hand over an API key). - To take a delegation back before it expires, add its
id(printed after signing) torevoked_delegations.toml— this is independent of, and finer-grained than, removing the delegator's ownidentity.tomlentry (which revokes every delegation they've ever issued).
Approving high-risk operations: yunohost-mcp-approve
Some operations (system_upgrade, backup_restore, backup_delete, system_migrate, user_delete, permission changes, firewall changes) require owner co-signature on top of the requester's own confirmation (PLAN.md Phase 13, solo profile - see docs/owner-approval-plan.md in the packaging repo for the full design). The requester's call pauses with a confirmation_id; the configured owner reviews and approves it with yunohost-mcp-approve, signing through their own NIP-46 remote signer app (Amber, nsec.app, ...) - their private key never touches this server or the requesting agent's machine.
One-time setup, on whatever device the owner keeps their signer app on:
yunohost-mcp-approve pair
Prints a nostrconnect:// URI to open in the signer app. This persists a reconnectable session locally so later approvals don't need to re-pair. If the signer app can instead export a bunker:// connection string itself (its own "add a connection" feature), yunohost-mcp-approve pair --bunker-uri <uri> connects immediately using that instead - no link to open, nothing to wait on.
To review and approve a specific pending operation:
yunohost-mcp-approve approve --server https://your-yunohost-domain/mcp --confirmation-id confirm-...
This fetches the authoritative pending-operation record from the server (never trusts a locally-supplied plan), displays the exact tool, arguments, and operation_hash, and requires typing yes before submitting the signed approval. Once approved, the original requester can retry its call.
Automatic push approval. Once paired, this step usually isn't needed at all: the moment a require_owner_signature operation is requested, the server itself reuses the same paired session to open a live NIP-46 connection and ask your signer app to sign a small, human-readable approval event right then - a real push prompt on your signer app, no command to run. Approving there marks the ticket approved directly; declining, timing out (YUNOHOST_MCP_OWNER_PUSH_APPROVAL_TIMEOUT_SECONDS, default 90s), or no session being paired yet just leaves the ticket pending for a manual yunohost-mcp-approve approve as above. Disable entirely with YUNOHOST_MCP_OWNER_PUSH_APPROVAL_ENABLED=false.
Development
uv sync --group dev
uv run pytest -q
Creating a release tag
Maintainers can run the GitHub Actions Tag release workflow manually from
the branch or commit to release, providing a version without the v prefix
(for example, 0.1.1). It validates the version, refuses to overwrite an
existing tag, runs the full CI checks on Python 3.11 and 3.12, and only then
pushes an annotated v<version> tag.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yunohost_mcp_connect-0.8.34.tar.gz.
File metadata
- Download URL: yunohost_mcp_connect-0.8.34.tar.gz
- Upload date:
- Size: 318.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96e7bf677b9d55436d30a581d1395a08f77b84480989afab1bbcb57195689384
|
|
| MD5 |
1e6cf37a884bae688492f0b98b667963
|
|
| BLAKE2b-256 |
6d58805c6d6e113258f172ad68944496415c9274a2e1a138e4397ae57bed68da
|
Provenance
The following attestation bundles were made for yunohost_mcp_connect-0.8.34.tar.gz:
Publisher:
publish-pypi.yml on imattau/yunohost-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yunohost_mcp_connect-0.8.34.tar.gz -
Subject digest:
96e7bf677b9d55436d30a581d1395a08f77b84480989afab1bbcb57195689384 - Sigstore transparency entry: 2735310494
- Sigstore integration time:
-
Permalink:
imattau/yunohost-mcp@08e0fc33fd1a0520c3048b619bf94e37e1664a9a -
Branch / Tag:
refs/heads/master - Owner: https://github.com/imattau
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@08e0fc33fd1a0520c3048b619bf94e37e1664a9a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file yunohost_mcp_connect-0.8.34-py3-none-any.whl.
File metadata
- Download URL: yunohost_mcp_connect-0.8.34-py3-none-any.whl
- Upload date:
- Size: 189.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
895ed0b16f2a86b3986f6a657e30a01be03efd13734498db9ea44e3d8cd8c494
|
|
| MD5 |
d75ab813ab71d2f7e84cbc0e31b12779
|
|
| BLAKE2b-256 |
4da43e73f04ca41ceb05d08b73df48823eda718f55a1238185570cd22e8afb4b
|
Provenance
The following attestation bundles were made for yunohost_mcp_connect-0.8.34-py3-none-any.whl:
Publisher:
publish-pypi.yml on imattau/yunohost-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
yunohost_mcp_connect-0.8.34-py3-none-any.whl -
Subject digest:
895ed0b16f2a86b3986f6a657e30a01be03efd13734498db9ea44e3d8cd8c494 - Sigstore transparency entry: 2735310543
- Sigstore integration time:
-
Permalink:
imattau/yunohost-mcp@08e0fc33fd1a0520c3048b619bf94e37e1664a9a -
Branch / Tag:
refs/heads/master - Owner: https://github.com/imattau
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@08e0fc33fd1a0520c3048b619bf94e37e1664a9a -
Trigger Event:
workflow_dispatch
-
Statement type: