ssmcp

mcp
Guvenlik Denetimi
Uyari
Health Uyari
  • License — License: MIT
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Low visibility — Only 7 GitHub stars
Code Gecti
  • Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Gecti
  • Permissions — No dangerous permissions requested

Bu listing icin henuz AI raporu yok.

SUMMARY

mcp

README.md

SSMCP

SSMCP mounts and forwards MCP services. It ships two independent commands.

  • ssmcp reads local resources and publishes them directly to the selected host over HTTPS.
  • ssmcpd runs on the receiving host, where it verifies bearer tokens and forwards requests to mounted MCP endpoints.

Meter is the separate account and billing project. It handles GitHub sign-in, OAuth authorization, Waffo orders, and traffic quotas. Run ssmcpd on its own for self-hosting, or connect it to Meter for commercial deployments. Commercial deployment guide

English · 简体中文

cargo install --path . --locked

GitHub Releases provides Linux, macOS, and Windows binaries, client installers, Arch package recipes, and the configuration-only Magisk ZIP for arm64 Android. Arch Linux users can install ssmcp from source through the AUR, or use ssmcp-bin for the official binaries. Magisk setup

Create ~/.config/ssmcp/config.toml or use ssmcp -F FILE. If XDG_CONFIG_HOME is set, SSMCP looks for ssmcp/config.toml there.

# Uncomment a complete preset to mount servers under its prefix. Edit path or prefix as needed.
#
# Codex → /mcp/codex/…
# [[imports]]
# path = "~/.codex/config.toml"
# prefix = "/codex"
# mount = true
#
# Claude Code → /mcp/claude/…
# [[imports]]
# path = "~/.claude.json"
# prefix = "/claude"
# mount = true
#
# Pi → /mcp/pi/…
# [[imports]]
# path = "~/.pi/agent/mcp.json"
# prefix = "/pi"
# mount = true
#
# Pi MCP Adapter → /mcp/pi-adapter/…
# [[imports]]
# path = "~/.pi/agent/mcp-adapter.json"
# prefix = "/pi-adapter"
# mount = true
#
# Gemini CLI → /mcp/gemini/…
# [[imports]]
# path = "~/.gemini/settings.json"
# prefix = "/gemini"
# mount = true
#
# Cursor → /mcp/cursor/…
# [[imports]]
# path = "~/.cursor/mcp.json"
# prefix = "/cursor"
# mount = true
#
# Shared MCP → /mcp/shared/…
# [[imports]]
# path = "~/.config/mcp/mcp.json"
# prefix = "/shared"
# mount = true

# Define a loopback HTTP MCP server named /local/notes.
[resources."/local/notes"]
url = "http://127.0.0.1:4100/mcp"

# A stdio server starts when an MCP client initializes a session.
# [resources."/local/tools"]
# command = "python3"
# args = ["notes_server.py"]
# cwd = "./tools"

# Left side: path under the account’s MCP root. /notes is served at /mcp/notes.
# Right side: publishing machine’s resource, written as resource:<name>.
# Use "/" on the left to mount directly at /mcp.
[mounts]
"/notes" = "resource:/local/notes"
# "/codex-notes" = "resource:/codex/notes"
# Uncomment installed CLI tools to publish them on /mcp/bin/!<name>.
# "/bin/!zrun" = "!zrun" # Execute shell commands efficiently.
# "/bin/!bash" = "!bash"
# "/bin/!zsh" = "!zsh"
# "/bin/!ssh" = "!ssh"
# "/bin/!python3" = "!python3"
# "/bin/!system-python" = "!/usr/bin/python3"
# Publish a local skill directory at /mcp/skills/$skill_a.
# "/skills/$skill_a" = "~/.agents/skills/skill_a"
# Publish all skills in a local directory at /mcp/skills/$$skills_a/<name>.
# "/skills/$$skills_a/" = "~/.agents/skills"

# Share an existing file or a directory from the publishing device.
# "/files/notes.txt" = "file:~/Documents/notes.txt"
# "/files/project" = "dir:~/Documents/project"

[hosts."alice@localhost"]
# Command alias: ssmcp dev selects this profile.
alias = "dev"
# Optional. Defaults to 443. Set this only if the receiving daemon uses another HTTPS port.
# server_port = 8443
# Environment variable in the shell running ssmcp with Alice’s account token.
token_env = "SSMCP_ALICE_TOKEN"
# For a private CA, use a PEM file relative to this config file.
# ca_file = "certs/dev-ca.pem"

# Optional host routes share the same namespace as [mounts].
# [hosts."alice@localhost".mounts]
# "/notes" = "resource:/codex/notes"

Set SSMCP_ALICE_TOKEN and resource variables in the publisher's ssmcp.env. Use ssmcp alice@localhost or its alias ssmcp dev to publish to the same host. To publish to another machine, use its hostname in the profile and command. The resources always come from the machine running ssmcp.

While the publish session is active, use https://localhost/mcp/notes in your MCP client and provide Alice’s token as Authorization: Bearer <token>. The same URL resolves to a different mount when authenticated as another account.

On connection, the publisher shows its hostname, the receiving endpoint and the mount counts by type.

laptop -> https://localhost/mcp (alice) | MCP 1 · Meta MCP 1 · Skill 0 · Skills 0 · CLI2MCP 0

Existing mount values such as "/local/notes" also work.

Imports and definitions register resources. For example, a server called notes imported with the /codex prefix becomes /codex/notes. Reference a resource from [mounts] or a host's mounts to expose it.

Imports read the TOML mcp_servers table or the JSON mcpServers and servers objects. Relative import paths resolve from the SSMCP config. Later imports replace resources with the same name, and explicitly defined resources take precedence. For the selected host, the first mount declared for a path owns it. Later collisions are logged with both sources and skipped. A trailing slash does not create a new path.

Set mount = true to publish the imported server names below the chosen prefix. SSMCP reads the config at startup and prepares each imported transport on first access. Idle stdio sessions and their processes are reclaimed after five minutes without work, including when an event stream remains open. Loopback HTTP servers manage their own lifecycle.

A mount value starting with ! runs a CLI executable on the publishing host. Bare names are looked up on its PATH and relative paths such as !./bin/formatter resolve from the SSMCP config directory. Each CLI mount exposes one tool that takes an optional args array of strings and returns stdout, stderr, and the exit code. For example, call zrun with {"args":["run","printf hello"]}.

A mount whose final path segment begins with $ serves a local skill directory. Its value is an absolute path, a path relative to the config, or a ~/ path under the publishing account’s home. Use the read tool to open SKILL.md or pass a relative path to read another text file inside the directory.

A path segment beginning with $$ creates a Meta directory. At publisher startup, each visible immediate subdirectory containing a SKILL.md is mounted under its directory name. Discovered skills claim their paths at the point where the collection is declared.

Define resources and their environment

Transport Configuration
stdio Set command. Use args for arguments and cwd for the working directory. env sets subprocess values and env_vars passes through variables by name.
streamable-http Set a loopback url. Set request headers with headers, or map a header to a variable with env_http_headers. Set bearer_token_env_var or bearer_token_file if the upstream requires a bearer token.

Both transports are prepared on first access. The publisher starts a stdio process on MCP initialization. Streamable HTTP connects to an independently running upstream and forwards its SSE streams. Local resource paths and working directories resolve relative to the TOML file. Imported resource paths resolve relative to their source configuration.

Publisher Environment file
Foreground or user service $XDG_CONFIG_HOME/ssmcp/ssmcp.env, or ~/.config/ssmcp/ssmcp.env by default
Foreground with -F FILE ssmcp.env beside FILE
System service /etc/ssmcp/ssmcp.env

Use one NAME=value assignment per line and set the file to mode 0600. Quotes preserve a value with spaces. Use ${NAME} in TOML to look up a value and ${NAME:-default} to provide a fallback when the variable is unset. Exported variables take precedence over the companion file when publishing from a terminal. Restart the publisher after editing the file.

Browse mounts with Meta MCP

Connect to https://<receiver>/mcp with your account's bearer token. The root and any directories implied by nested mounts automatically serve the built-in Meta MCP. Use "meta" in a mount entry to create an empty directory. An explicit resource mount at any path takes precedence. To use your own Meta MCP implementation, mount it as a regular resource.

[mounts]
# SSMCP serves /mcp, /mcp/dev and /mcp/dev/tools automatically.
"/dev/tools/notes" = "resource:/local/notes"
# Give an empty directory its own MCP endpoint at /mcp/dev/empty.
"/dev/empty" = "meta"

The only MCP tool is shell. Pass one command as its command argument.

Command Action
help Show command syntax.
ls [path] List immediate children or inspect a file. With no path, list the current directory.
read [path] Read a mounted UTF-8 text file.
edit {"path":"/files/notes.txt","text":"new contents"} Replace an existing text file.
create {"path":"/files/project/new.txt","text":"hello"} Create a text file in a mounted directory without overwriting an existing entry.
cd [path] Change directory. Use cd .. for the parent or cd to return to the session root.
chroot <path> Use a directory as the new session root. Absolute paths start at that root.
exec [path] Select a mounted MCP and see its tool definitions. For a built-in Meta directory, enter the directory. Omit the path to clear the selection.
call <tool> [JSON object] Invoke a tool on the selected downstream MCP.

File and directory rows include modification time (Unix seconds) and permissions. Use a JSON path such as read {"path":"/files/project/my notes.txt"} when the filename contains spaces. File operations support up to 256 KiB per file. Use "encoding":"base64" when reading binary data, or provide a base64 field instead of text when writing. A native mount owns its subtree, and the first configured mount wins on overlap. To disable writes, define a resource with type = "file" or type = "directory", path, and read_only = true, then mount its resource:/... name. Meter's Mounted resources page can browse directories and preview text.

For example, run exec /dev/tools/notes and then call read_note {"id":"42"}. The root, working directory and selected MCP belong to the current session. The receiver authenticates and initializes /mcp even when the account has no publisher online. A session started in the empty receiver view can reconnect to browse newly published mounts.

Use enter /bash to save the current directory and selection, then exit to return to them. exec /bash replaces the current selection in place.

If the client opens a fresh MCP session per tool call, use the context returned by exec or enter. For example, after enter /bash, run resume <context> call bash {"args":["-c","printf hello"]}, and then resume <context> exit. The context keeps the original shell state for the same endpoint and expires after five minutes of inactivity.

A direct ssmcp user@host works without a host profile. It uses HTTPS port 443 and the shared [mounts] table. Use a host profile for an alias, a custom port, or per-host mounts.

Sign in with OAuth

On a Meter-enabled deployment, use the connection name shown on your account page in [hosts."[email protected]"] and omit token_env. If the alias is work, authorize the publisher once and start publishing:

ssmcp login work
ssmcp work

You can also run ssmcp login [email protected] before creating a host profile.

In a remote MCP client, add the HTTPS mount URL and sign in with the same GitHub account. In Codex:

codex mcp add notes --url https://mcp.example.com/mcp/notes

If Codex does not prompt for authorization, run codex mcp login notes.

A user systemd service uses the same saved authorization when it runs under the user who ran ssmcp login. A standalone receiver uses the manually issued credential shown below.

Background publishing

The Arch ssmcp and ssmcp-bin packages install system and user variants of ssmcp.service, plus the receiver unit ssmcpd.service. To install the units from source, run sudo make install-systemd.

Select a configured host alias or user@host in the publisher TOML:

[background]
# Use the alias or the full user@host from one of your [hosts] entries.
target = "dev"

Run one publisher service per machine. Choose the scope that fits the resources it publishes.

  • User service. Put the configuration in $XDG_CONFIG_HOME/ssmcp/config.toml, which defaults to ~/.config/ssmcp/config.toml. Put tokens and other required environment variables in ssmcp.env in the same directory with mode 0600. Run systemctl --user enable --now ssmcp.service. Use loginctl enable-linger "$USER" if it needs to run after logout.
  • System service. Put the configuration in /etc/ssmcp/config.toml and environment variables in /etc/ssmcp/ssmcp.env. Both files can be root-owned with mode 0600. Relative paths resolve from /etc/ssmcp. The service account needs access to imported files, CA certificates and stdio programs. Its home is /var/lib/ssmcp. Run sudo systemctl enable --now ssmcp.service.

Use one NAME=value per line in the environment file. Restart the chosen service to apply configuration changes. Check the published addresses with journalctl --user -u ssmcp.service -f or sudo journalctl -u ssmcp.service -f.

To use a configured alias as the service target, start an instance of [email protected]. For example, run systemctl --user start [email protected] for the alias dev. The instance supplies the target directly. For a full destination or an alias requiring escaping, run:

unit=$(systemd-escape [email protected] '[email protected]')
systemctl --user start "$unit"

For the system scope, use sudo systemctl start "$unit" with the alias or destination configured for that scope. Stop the regular service before starting an instance for the same account.

The Omarchy widget shows both service scopes, selects template instances, follows the selected unit’s journal, and edits TOML with completion and theme colors. Stop also disables an enabled unit. Copy the contents of /usr/share/ssmcp/omarchy into ~/.config/omarchy/plugins/io.github.lightjunction.ssmcp/ and run omarchy plugin enable io.github.lightjunction.ssmcp. Editing system configuration uses Polkit authorization. Use systemctl cat ssmcp.service to check paths selected by a custom unit or drop-in.

Left-click the Omarchy widget to manage mounts. Right-click to open the publisher services. Drag a registered resource from a local folder such as /codex/ to the receiver tree. An alias such as /dev/ points to /mcp.example.com:443/. Right-click a receiver directory to create an MCP, CLI, skill, collection, or directory mount. Edit TOML opens the text editor. The widget defaults to English and follows Omarchy’s language setting for Simplified Chinese. Right-click the local pane to register another resource without mounting it. The live log groups repeated messages and shows their count.

Run the server

Use systemd to run ssmcpd on the receiving host. To install from source, build as your regular user, then install the binaries and the unit.

make build
sudo make install-built install-systemd

If a package already installed the binary under /usr/bin and did not include a unit, run sudo make install-systemd PREFIX=/usr from the source checkout.

Write the following to /etc/ssmcpd/tunnel.toml and place the TLS files where the configuration points.

sudo mkdir -p /etc/ssmcpd
sudoedit /etc/ssmcpd/tunnel.toml
[server]
# One HTTPS listener for MCP requests and publishing tunnels.
listen = "0.0.0.0:443"
# PEM files for the TLS certificate chain and private key.
cert = "/etc/ssmcpd/fullchain.pem"
key = "/etc/ssmcpd/privkey.pem"
# Server-only key used to sign and verify account tokens.
token_key_env = "SSMCP_TOKEN_KEY"

Create the server signing key once. Systemd reads it from the root-only /etc/ssmcpd/ssmcpd.env file. This command preserves an existing file.

sudo sh -c 'umask 077; set -C; key=$(openssl rand -hex 32) && printf "SSMCP_TOKEN_KEY=%s\n" "$key" > /etc/ssmcpd/ssmcpd.env'

Enable the service and start it.

sudo systemctl daemon-reload
sudo systemctl enable --now ssmcpd.service
systemctl status ssmcpd.service

Use journalctl -u ssmcpd.service -f to follow the logs. After editing the configuration or environment file, run sudo systemctl restart ssmcpd.service to apply the changes.

Issue a token manually

On the receiving host, load the service’s signing key and issue a 30-day SSMCP credential for Alice.

sudo sh -c 'set -a; . /etc/ssmcpd/ssmcpd.env; set +a; exec ssmcpd token alice'

Alice can use it to authenticate the publisher and connect her MCP client to her own mounts. Use Meter for account sign-in and billing.

The tunnel uses WebSocket over TLS. The publisher validates the certificate and hostname, including localhost. Use ca_file in the host profile for a private CA in PEM format.

MCP resources

  • Awesome MCP Servers is a community-maintained directory for finding MCP servers to run and publish with SSMCP.
  • SSHarness is a local MCP service for terminal sessions. Mount its loopback endpoint as a Streamable HTTP resource and point bearer_token_file at its private credential file. SSHarness publishing example

Development

Run cargo test --locked for the Rust tests. make test also exercises both binaries end to end with real TLS using Python and OpenSSL test fixtures.

MIT license

Yorumlar (0)

Sonuc bulunamadi