Skip to content

feat: comment processing, description fallback and file header (port from Go) #4

Closed

Description

@erikist

Part of #2. Port the text helpers in Go's cmd/protoc-gen-go-mcp/mcp.go at 9e072f9, with their tests from mcp_test.go. Tool descriptions and schema descriptions both depend on them, so their output must match Go's character for character.

Do

  • Comments. Look up leading comments from SourceCodeInfo by path: the method, the message, the field, the enum, and the syntax/package detached comments for the file header.
  • process_comment_to_string: a port of processCommentToString.
    • Handle line comments (strip // from continuation lines) and block comments (strip /* and */).
    • Join the lines with spaces, trim, and collapse whitespace runs into one space.
    • Do not escape anything; callers escape for their own context. This was a real bug in Go (#100): escaping here and again in the caller produced double escaping.
  • camel_to_space: a port of camelToSpace, the fallback description when a method has no comment (e.g. SetVibeDetails → Set Vibe Details). Include the letter↔digit boundaries.
  • File header: // @generated by protoc-gen-rust-mcp. DO NOT EDIT., followed by // versions: with the plugin version and protoc vX.Y.Z[-suffix] (or (unknown)) from compiler_version. This mirrors Go's protocVersion.
  • Rust string literals: a helper that emits arbitrary text, such as descriptions and the JSON schema, as a valid Rust literal. Prefer a raw string r#"…"# with enough #s; it must survive any comment text, including "#, backslashes and backticks.

Acceptance criteria

  • Port every case in Go's TestProcessCommentToString and TestUnexport/TestQuoteBacktickString (or their Rust-literal equivalents), plus the example proto's tricky comments: the block comment on SetVibe (quotes, a backtick, C:\vibes\new) and the multi-line GetVibe comment with its trailing empty // line. Each expected string must equal Go's output; take the expected values from the descriptions in Go's committed examples/gen/example/v1/example_mcp.pb.go.
  • Add a property test or table test showing that the literal helper round-trips any string through syn::parse_str::<syn::LitStr>, or something equivalent.
  • The checks in AGENTS.md pass.

Activity

  1. erikist commented on Oct 9, 2026

    @erikist
    ContributorAuthor

    🤖 Factory: picked up by dispatcher; working on branch factory/4-feat-comment-processing-description-fallback-and.

  2. erikist commented on Oct 9, 2026

    @erikist
    ContributorAuthor

    🤖 Factory: opened PR #19 implementing comment processing, description fallback and the file header, ported from Go's cmd/protoc-gen-go-mcp/mcp.go (commit 9e072f9). All checks in AGENTS.md pass; details and test evidence in the PR.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    factory:in-progressAn sf-factory worker is on itfactory:readyReady for the sf-factory to pick up

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions