Skip to content

feat(mcp): add API-derived stdio server - #205

Open
KalebCole wants to merge 8 commits into
mainfrom
feat/issue-204-mcp-server
Open

KalebCole wants to merge 8 commits into
mainfrom
feat/issue-204-mcp-server

Conversation

@KalebCole

@KalebCole KalebCole commented Sep 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add partiful mcp using the official github.com/modelcontextprotocol/go-sdk over stdio
  • derive the 18 supported product tools, schemas, safety annotations, validation, auth, privacy projections, dry-run behavior, and mutation dispatch from the existing CLI application catalog
  • expose reads and writes by default; support narrowing with --read-only and repeatable/comma-separated --allow-tool; add --list-tools
  • return compatible JSON text plus structured content and add an official-SDK black-box stdio test

Validation

  • go mod verify
  • go test -count=1 ./...
  • go test -race -count=1 ./...
  • go vet ./...
  • go build ./...
  • git diff --check
  • scripts/pii-guard.sh

Stack

This PR targets fix/issue-201-dry-run-confirmation at 985013b. Retarget it to main only after #202 and #203 land.

Closes #204 after merge.

Summary

  • add partiful mcp using the official github.com/modelcontextprotocol/go-sdk over stdio
  • derive the supported product tools, schemas, safety annotations, validation, auth, privacy projections, dry-run behavior, and mutation dispatch from the existing CLI application catalog
  • expose reads and writes by default; support narrowing with --read-only and repeatable/comma-separated --allow-tool; add --list-tools
  • return compatible JSON text plus structured content and add an official-SDK black-box stdio test

Validation

  • go test ./...
  • go test -race ./...
  • go vet ./...
  • go build ./...

Rebase

#202 and #203 are already on main. This branch is rebased onto current main. partiful mcp --help still prints local usage and returns before the stdio server, and MCP-generated errors still include cliVersion plus the contract revisions. The rebase also keeps auth login's --no-input check on the local flag, because mutationExecution now carries a confirmation callback instead of a NoInput field.

Closes #204 after merge.

Open in Web Open in Cursor 

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f7043956-29c3-4567-8501-2cdd97c87f39
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1

🚀 View preview at
https://KalebCole.github.io/partiful-cli/pr-preview/pr-205/

Built to branch gh-pages at 2026-09-05 18:26 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@KalebCole
KalebCole marked this pull request as draft September 5, 2026 01:09
@KalebCole

Copy link
Copy Markdown
Owner Author

The first implementation does not yet satisfy #204 and should not be reviewed as merge-ready.

The blocking issue is architectural: MCP arguments are converted into synthetic CLI argv and routed through the CLI parser. That makes CLI parsing the shared layer instead of the API-derived application operation, and it already causes schema/runtime drift for nested, nullable, numeric, and union inputs.

Required recovery order:

  1. Extract one typed operation invocation seam used by both CLI and MCP.
  2. Keep argv parsing and TTY confirmation in the CLI adapter.
  3. Decode MCP arguments directly into the same typed operation inputs.
  4. Rebuild and test the exact 18-tool catalog and schemas on that seam.
  5. Add output-schema validation, runtime bounds, and release compatibility.

The existing implementation also needs the snake_case cohost tool name fixed, complete schema parity, truthful bounded-result behavior, and a green native-release workflow.

Writes remain enabled by default. --read-only and --allow-tool only narrow the surface. No --allow-write gate should be introduced.

Keeping this PR open as a draft while the architecture is corrected. Nothing should merge from the current head.

  • hermes 🤖

@KalebCole
KalebCole marked this pull request as ready for review September 5, 2026 04:23
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

partiful mcp lacks a conventional --help path and MCP-layer failure envelopes omit standard CLI meta, creating usability and response-shape inconsistencies.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 2 Medium severity

New issues introduced by this change (2)
Severity Finding
Medium severity cmd/​partiful/​main.go — partiful mcp currently treats -h/--help as an unknown option (because it runs through…
Medium severity internal/​mcpserver/​server.go — The MCP-layer error envelopes (MCP_ARGUMENTS_INVALID, MCP_OUTPUT_INVALID, call timeout/cancel,…
What changed in this PR

Adds an API-derived MCP stdio server to the existing partiful binary (partiful mcp) by reusing the CLI’s typed operation catalog and execution path, plus supporting runtime limits and parity/SDK black-box tests.

Changes:

  • Introduce an MCP stdio server (internal/mcpserver, cmd/partiful entrypoint) that exposes curated product operations as tools with derived input/output schemas and bounded runtime behavior.
  • Refactor CLI execution to parse into a shared typed “product operation” invocation used by both CLI and MCP adapters (including dry-run and destructive-confirmation behavior).
  • Update tooling/docs/CI for Go/toolchain upgrades and include MCP usage + smoke/verification updates.
File Description
scripts/​smoke-native-cli.sh Run smoke checks under isolated HOME/config roots for safer native verification.
README.md Document MCP stdio server usage, flags, and runtime safeguards; update release rehearsal snippet.
internal/​mcpserver/​server.go Implement MCP server option parsing, tool filtering, schema validation, pacing, concurrency, and output bounds.
internal/​mcpserver/​server_test.go Unit tests for MCP option parsing and tool filtering behavior.
internal/​mcpserver/​server_runtime_test.go In-memory runtime tests covering schema validation, pacing, limits, cancellation/timeout, and tool parity basics.
internal/​app/​rsvp.go Refactor RSVP get execution to accept typed inputs (no argv parsing inside executor).
internal/​app/​rsvp_set.go Refactor RSVP set execution to accept typed options (no argv parsing inside executor).
internal/​app/​posters.go Extract posters execution into shared operation function and add truncation metadata support.
internal/​app/​operation.go Add shared typed product invocation model and dispatch for CLI + MCP adapters.
internal/​app/​mcp.go Add MCP tool catalog derivation, input/output schema projection, and MCP argument decoding into typed invocations.
internal/​app/​mcp_operation_test.go Verify CLI and MCP adapters generate identical typed invocations for all exposed tools.
internal/​app/​mcp_execution_test.go Parity + safety tests for MCP execution behavior (dry-run, auth, redaction, bounds, confirmations).
internal/​app/​mcp_catalog_test.go Validate curated MCP tool set and ensure CLI-only fields aren’t exposed via tool schemas.
internal/​app/​guests.go Refactor guest list/invite executors to accept typed inputs and emit truncation metadata.
internal/​app/​events.go Refactor event list/get executors to accept typed inputs and emit truncation metadata.
internal/​app/​event_write.go Refactor event write executors to accept typed inputs; route confirmation through new execution hook.
internal/​app/​contacts.go Extract contacts execution into shared operation function and add truncation metadata support.
internal/​app/​confirmation.go Refactor mutation execution confirmation handling to support CLI-only prompting and MCP non-interactive behavior.
internal/​app/​cohosts.go Refactor cohost executors to accept typed inputs and use shared confirmation hook.
internal/​app/​blasts.go Refactor blast send executor to accept prepared typed input; split message preparation into helper.
internal/​app/​app.go Route product operations through shared parse+invoke path; extend page metadata for truncation; refactor confirmation plumbing.
go.sum Add/upgrade module sums for MCP SDK, jsonschema, and updated x/* dependencies.
go.mod Bump Go version and add MCP/jsonschema dependencies (plus indirects).
docs/​index.html Update website installation/verification command to new toolchain + GoReleaser versions.
docs/​CONTRIBUTING.md Update contributor verification command to new toolchain + GoReleaser versions.
cmd/​partiful/​mcp_test.go Black-box stdio tests using the official MCP SDK + lifecycle/stdio behavior checks.
cmd/​partiful/​main.go Add partiful mcp entrypoint and dependency wiring; --list-tools support.
.github/​workflows/​release.yml Bump CI Go version and GoReleaser install path/version.
.github/​workflows/​native-release-verify.yml Bump CI Go version and GoReleaser install path/version.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/partiful/main.go Resolved
Comment thread internal/mcpserver/server.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

--read-only currently does not prevent credential refresh persistence on protected read tools, which undermines the intended “no local credential mutation” safety surface.

Review tier: Lite
Findings: None

Issues resolved since last review (2)
Severity Finding
Medium severity internal/​mcpserver/​server.go — The MCP-layer error envelopes (MCP_ARGUMENTS_INVALID, MCP_OUTPUT_INVALID, call timeout/cancel,… View resolved comment
Medium severity cmd/​partiful/​main.go — partiful mcp currently treats -h/--help as an unknown option (because it runs through… View resolved comment
Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

internal/mcpserver/server.go:236

  • --read-only currently filters tools based on app.MCPDefinition.ReadOnly but does not prevent refresh-token persistence for protected read tools. Protected reads (e.g., contacts_list, events_list, events_get, rsvp_get) still call acquireProtectedSession, which uses auth.AcquireSession (persistRefresh=true) and will write updated credentials to disk on refresh, mutating local credential state even in read-only mode.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

partiful mcp help currently fails when combined with other flags, and the docs-site rehearsal snippet sets a global EXIT trap without a subshell, both of which should be corrected before approval.

Review tier: Lite
Findings: None

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

docs/index.html:479

  • The docs site command snippet sets an EXIT trap in the caller’s shell (trap 'rm -rf "$gobin"' EXIT) without a subshell. If users paste this, it can override an existing EXIT trap (and the cleanup won’t run until their shell exits). Wrapping the sequence in ( ... ) (like README/CONTRIBUTING now do) scopes the trap and avoids surprising shell-side effects.

cmd/partiful/main.go:55

  • partiful mcp help only works when -h/--help is the only flag (len(argv)==1). If a user runs partiful mcp --help --read-only (or similar), --help falls through to ParseOptions and becomes an "unknown mcp option", exiting 2 instead of showing usage. Help flags should be recognized regardless of what other flags are present, and should short-circuit before starting the MCP transport.
func runMCP(ctx context.Context, argv []string, dependencies app.Dependencies) error {
	if len(argv) == 1 && (argv[0] == "-h" || argv[0] == "--help") {
		_, err := io.WriteString(os.Stdout, mcpserver.HelpText())
		return err
	}

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

cmd/partiful/mcp_test.go spawns subprocesses with only HOME set, which can read/write real user config on Windows (os.UserConfigDir via APPDATA/LOCALAPPDATA), making tests non-hermetic cross-platform.

Review tier: Lite
Findings: None

Suppressed comments (4)

Previously missed (1) — in code that hasn't changed since the last review.

cmd/partiful/mcp_test.go:30

  • The MCP process only sets HOME for isolation, but auth.DefaultCredentialsPath uses os.UserConfigDir (APPDATA/LOCALAPPDATA on Windows). This can cause the test to read/write real user config when run on Windows. Set XDG_CONFIG_HOME/APPDATA/LOCALAPPDATA alongside HOME so the subprocess is hermetic across platforms.

This issue also appears in the following locations of the same file:

  • line 135
  • line 227
  • line 268

cmd/partiful/mcp_test.go:271

  • startRawMCP sets only HOME for the subprocess, but config resolution on Windows uses APPDATA/LOCALAPPDATA via os.UserConfigDir. Also, using t.TempDir() directly in the Env assignment prevents reusing the same directory for all vars. Set HOME/XDG_CONFIG_HOME/APPDATA/LOCALAPPDATA from a single temp dir to avoid touching real user config on Windows.
func startRawMCP(t *testing.T, binary string) *rawMCPProcess {
	t.Helper()
	command := exec.Command(binary, "mcp", "--request-interval", "1ms")
	command.Env = append(os.Environ(), "HOME="+t.TempDir())

cmd/partiful/mcp_test.go:137

  • This subprocess only sets HOME, but os.UserConfigDir (used by auth.DefaultCredentialsPath) reads APPDATA/LOCALAPPDATA on Windows. Also, calling t.TempDir() inside Env assignment makes it hard to reuse the same directory for all relevant vars. Create one temp dir and set HOME/XDG_CONFIG_HOME/APPDATA/LOCALAPPDATA consistently.
			var stdout, stderr bytes.Buffer
			command := exec.Command(binary, append([]string{"mcp"}, test.argv...)...)
			command.Env = append(os.Environ(), "HOME="+t.TempDir())

cmd/partiful/mcp_test.go:229

  • This subprocess only sets HOME, but auth.DefaultCredentialsPath uses os.UserConfigDir, which depends on APPDATA/LOCALAPPDATA on Windows. Use a single temp dir and set HOME/XDG_CONFIG_HOME/APPDATA/LOCALAPPDATA so the test remains hermetic on all platforms.
		var stdout, stderr bytes.Buffer
		command := exec.Command(binary, "mcp", "--invalid-option")
		command.Env = append(os.Environ(), "HOME="+t.TempDir())

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It introduces a new MCP protocol surface and refactors core execution/auth/persistence pathways, warranting final human security/correctness review despite strong automated test coverage.

Review tier: Lite
Findings: None

@KalebCole
KalebCole force-pushed the fix/issue-201-dry-run-confirmation branch from 81de1eb to ff9bdb4 Compare September 5, 2026 23:59
KalebCole and others added 7 commits November 12, 2026 22:25
Replace the MCP-to-argv bridge with shared typed product operations used by
both CLI and MCP adapters. Add curated read/write tools, schema validation,
privacy-safe errors, runtime bounds, lifecycle handling, and parity coverage.

Keep writes enabled by default with read-only and allow-tool narrowing.
Main reads --no-input into a local flag and confirms destructive commands
through a callback. The rebased login path still referenced
execution.NoInput, which that struct no longer has.

Co-authored-by: Kaleb Cole <[email protected]>

Copy link
Copy Markdown
Owner Author

Triage bot: held for Kaleb. An MCP server is a second product interface and is on the hold list. Separate from the architecture blockers already noted above. Also has merge conflicts with main. Not merging.

@KalebCole KalebCole added enhancement New feature or request held Waiting on Kaleb's decision. Do not merge. labels Nov 14, 2026 — with Cursor

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request held Waiting on Kaleb's decision. Do not merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a DRY, API-derived MCP server to partiful-cli

3 participants