feat(mcp): MCP server + Skills for Claude/Codex/Gemini - #7
Merged
Conversation
The key/argon2/encrypt/create/URL and fetch/decrypt glue moves from the cobra commands into a transport-agnostic internal/share service (with its own httptest round-trip tests) so the upcoming MCP server reuses identical logic. CLI behavior is unchanged; all unit and e2e tests pass.
internal/mcpserver builds an mcp.Server (official Go SDK) exposing send_secret, send_file, receive_secret (omitted with --read-only), list_profiles and server_version, reusing internal/share. Config/profile resolved per call from the host ypcli config. ypcli mcp serves it over stdio. In-memory client round-trip tests cover every tool.
ypcli mcp --http serves the MCP server over Streamable HTTP; a constant-time bearer-token middleware gates it (required, from --http-token/$YPCLI_MCP_TOKEN). Graceful shutdown on signal. Adds a hardened systemd unit (DynamicUser, ProtectSystem=strict, no caps, syscall filter) and deploy/README.
skills/ypcli/SKILL.md (Agent Skill), integrations/ with ready-to-copy MCP config for Claude (.mcp.json), Codex (config.toml + prompt) and Gemini (settings.json + extension), each with stdio and HTTP variants.
- clientFor now honors $YPCLI_TOKEN for upstream yopass auth (was hardcoded '') - send_file requires an absolute path and its description/docs warn that it reads arbitrary local files (prompt-injection exfiltration risk) - list_profiles output is sorted (deterministic) - add MCP error-path, binary/base64, profile-honored, and CLI --http-token usage tests; drive real requests through the HTTP auth handler - doc-comment the no-token Handler; minor bytes.NewReader micro-opt
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an MCP server (
ypcli mcp) exposing ypcli's send/receive to AI agents, plus Skills/config for Claude, Codex, and Gemini, and a server-install path — implemented per the agreed plan (stdio + HTTP; full send+receive tool set; skills for all three).What's included
internal/share— the send/receive core extracted from the CLI (DRY), reused by both the CLI and MCP. CLI behavior unchanged (unit + e2e green).internal/mcpserver— MCP server on the official Go SDK (modelcontextprotocol/go-sdkv1.6.1). Tools:send_secret,send_file,receive_secret(omitted by--read-only),list_profiles,server_version. Typed IO with JSON Schema; config/profile resolved per call.ypcli mcp— serves over stdio (default) or HTTP (--http, mandatory constant-time bearer token, graceful shutdown).skills/ypcli/SKILL.md(Claude Agent Skill),integrations/(ready-to-copy Claude/Codex/Gemini configs, stdio + HTTP),deploy/(hardened systemd unit + guide).docs/{en,ru}/09-mcp.md, CLI reference, indexes, CHANGELOG.Independent review
An independent review agent audited the branch; findings were integrated:
$YPCLI_TOKENnow honored in MCP mode,send_filerequires an absolute path and its risk is documented prominently,list_profilessorted, added error-path/binary/profile/CLI tests, HTTP handler hardening comments.Verification
go build,golangci-lint,go vet,goreleaser check— clean.go test -race ./...— all pass; total coverage 73.3% (mcpserver 83.6%).ypcli mcpover stdio against a live yopass container returns a genuine share URL; HTTP mode verified (401 without token, MCP handshake with token).🤖 Generated with Claude Code