Repository navigation
feat: mcp-vibe example server over stdio (#10) - #27
Merged
Merged
Conversation
Add the `mcp-vibe` binary (`examples/src/bin/mcp-vibe.rs`), the Rust counterpart of Go's `cmd/mcp-vibe/` at 9e072f9: - starts an in-process tonic `VibeService` backend on 127.0.0.1:0, with SetVibe/GetVibe behaving like Go's vibe.go (initial vibe "initial vibe", empty vibe -> error "vibe cannot be empty"); the other RPCs return Unimplemented - connects a tonic client to it, builds a VibeServiceMcpServer and calls register_default_tools() - serves MCP over stdio with server info name "vibe", version "0.0.1", shutting down cleanly on SIGINT/SIGTERM or stdin EOF Also: - moves rmcp's "transport-io" and tonic's "router" features, and tokio, from dev-dependencies to normal dependencies of examples/Cargo.toml (binaries can't use dev-dependencies), with comments explaining why - adds examples/tests/mcp_vibe_binary.rs, spawning the real binary as a subprocess via rmcp::transport::TokioChildProcess and driving it through initialize, tools/list, and tools/call (SetVibe then GetVibe) - fills in README.md's mcp-vibe install TODO
3 tasks
Contributor
Author
|
🔍 Review: LGTM. Side-by-side check against Go: I sent the same stdio session (
Matching Go's real |
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.
Closes #10
Summary
Adds the
mcp-vibebinary (examples/src/bin/mcp-vibe.rs), the Rust counterpart of Go'scmd/mcp-vibe/(stablekernel/protoc-gen-go-mcpat9e072f9):VibeServicebackend on127.0.0.1:0with a process-wide vibe starting at"initial vibe".SetVibe/GetVibebehave like Go'svibe.go:SetVibewith an empty vibe returns an error with message"vibe cannot be empty". Go's handler returns a plainfmt.Errorf, which grpc-go reports to the client ascodes.Unknown(the default for a non-Statuserror, notInvalidArgument), so the Rust backend usestonic::Status::unknownto match. The other three RPCs (SetVibeDetails,SetVibeArray,SetVibeObjects) returnUnimplemented, as in Go.VibeServiceClientto the in-process backend, buildsVibeServiceMcpServer::new(client).with_server_info(Implementation::new("vibe", "0.0.1")), and calls.register_default_tools().rmcp::transport::io::stdio()), shutting down cleanly on SIGINT/SIGTERM (viatokio::signal) or stdin EOF (the transport closing naturally resolvesrunning.waiting()).Also, since binaries can't use
[dev-dependencies]:tonic's"router"feature (needed forServer::builder().add_service(...)) andrmcp's"transport-io"feature fromexamples/Cargo.toml's[dev-dependencies](wheretests/handler.rsneeded them) to[dependencies], now thatmcp-vibeneeds them too as a normal binary.tokio(withrt-multi-thread,macros,net,signal) as a normal dependency for the same reason.rmcp's"client"feature as a dev-dependency (only tests need an MCP client), and adds"transport-child-process"to it for the new binary test below.Decisions
SetVibe's empty-vibe error code: matched Go's actual wire behavior (codes.Unknown) rather than the more semantically-fittingInvalidArgument, since parity with the Go reference takes precedence here perAGENTS.md.[[bin]]lives inexamples/Cargo.toml(examples/src/bin/mcp-vibe.rs), matching the issue's "or wherever it lives" andcargo install --path examples --bin mcp-vibe.Smoke test (issue's acceptance criterion)
Built
cargo build -p examples --bin mcp-vibe, then pipedinitialize,notifications/initialized,tools/list, andtools/callofSetVibethenGetVibeinto the binary:Input:
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"smoke-test","version":"0.0.1"}}} {"jsonrpc":"2.0","method":"notifications/initialized"} {"jsonrpc":"2.0","id":2,"method":"tools/list"} {"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"SetVibe","arguments":{"vibe":"chill"}}} {"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"GetVibe","arguments":{}}}stdout (the
tools/listresponse is abbreviated to just the tool names below; full input schemas in that response match the existingexamples/tests/mcp_tool_parity.rsfixtures):{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2025-06-18","capabilities":{"tools":{}},"serverInfo":{"name":"vibe","version":"0.0.1"}}} {"jsonrpc":"2.0","id":2,"result":{"tools":[/* GetVibe, SetVibe, SetVibeArray, SetVibeDetails, SetVibeObjects, full schemas omitted for brevity */]}} {"jsonrpc":"2.0","id":3,"result":{"content":[{"type":"text","text":"{\"previousVibe\":\"initial vibe\",\"vibe\":\"chill\"}"}],"isError":false}} {"jsonrpc":"2.0","id":4,"result":{"content":[{"type":"text","text":"{\"vibe\":\"chill\"}"}],"isError":false}}stderr:
(responses to requests 3 and 4 arrive out of request order in one run depending on scheduling, since nothing in the protocol requires in-order completion of pipelined
tools/calls against the same tool registry map —idis correct andGetVibealways echoes whateverSetVibeset.)Also verified separately:
SIGTERMandSIGINTto a runningmcp-vibe(reading from a FIFO, so stdin never hits EOF on its own) both cause a clean, prompt exit.cargo install --path examples --bin mcp-vibebuilds and installs successfully; the installed binary behaves the same as above.Test evidence
No proto or generator changes, so
make generate/examples/src/gen/are untouched.Toolchain checked:
rustc 1.99.0,cargo 1.99.0(fromrustc --version/cargo --versionin this environment, matchingrust-toolchain.toml).rmcppinned at3.5already inexamples/Cargo.toml; confirmedrmcp 3.5.1(latest3.5.x) is what actually resolves (cargo tree -p rmcp), and that it exposestransport::TokioChildProcess/ConfigureCommandExtunder itstransport-child-processfeature, andtransport::io::stdio()undertransport-io, by reading the crate source in the local registry cache.Self-review
Ran the
reviewersubagent once against this branch and the issue's acceptance criteria. It flagged:SetVibe's error code should match Go's actualcodes.Unknown(notInvalidArgument) — fixed.Re-ran all checks after these fixes; still green.
Notes for reviewers
tonic::Status::unknownfor the empty-vibe error is a deliberate parity choice (see Decisions above), not an oversight — happy to change if a human disagrees with weighing Go-parity over a more idiomatic gRPC code here.The signal-watcher task spawned in
mainis not explicitly joined/aborted whenmcp-vibeexits via the stdin-EOF path; it's harmless because the process exits right afterwaiting()returns, but flagging it since the reviewer agent noted it.No new follow-up issues filed; this is believed to fully close out feat: mcp-vibe example server over stdio #10.
Factory-authored