Add MCP tool to create line-anchored code comments on pull requests #5
Hille opened 2 months ago

The MCP server currently exposes getPullRequestCodeComments but no corresponding create tool. The only PR-commenting write tool creates general discussion comments, not line-anchored ones. This means AI assistants using TOD for code review can read existing review comments but can't leave their own inline feedback — they have to fall back to top-level PR comments that lose the file/line context.

I'd like to contribute a createPullRequestCodeComment MCP tool, but while investigating the implementation path I hit a gap that needs your input before I write any code.

What I found:

After inspecting the WADL and CodeCommentResource.java, CodeCommentResource only exposes GET and DELETE on individual comments — there is no POST endpoint to create a code comment via the REST API. The mcp-helper proxy also has no corresponding create-pull-request-code-comment endpoint. So implementing this tool requires work on two levels:

  1. A new REST or mcp-helper endpoint on the OneDev server side to create a code comment and associate it with a PR
  2. The TOD client tool that calls that endpoint

Questions before I start:

  1. Would you be willing to implement the server-side endpoint yourself? I'd focus purely on the TOD client tool once the endpoint is in place.
  2. If you do add the server-side endpoint, should it be a new entry in the mcp-helper (e.g. POST /~api/mcp-helper/create-pull-request-code-comment) or a proper POST /~api/code-comments on CodeCommentResource?
  3. For the TOD tool parameters, I was thinking: pullRequestReference, filePath, line, side (old/new, optional, default new), and content. Does that match how you'd expect the Mark and CompareContext to be populated server-side?
  4. Should replying to an existing code comment be the same tool with an optional replyToCodeCommentId parameter, or a separate tool?
  5. Any coding conventions beyond what's visible in mcp_command.go?
  • Hille changed fields 2 months ago
    Name Previous Value Current Value
    Assignee
    hille
    empty
  • Hille commented 2 months ago

    I edited the issue because after some investigation I found that there is no API endpoint for code comments.

  • Robin Shen commented 2 months ago

    Thanks for creating the issue. Will investigate adding restful api for code comment creation.

  • Robin Shen commented 3 weeks ago

    Already possible with new tod cli and skills

  • Robin Shen changed state to 'Closed' 3 weeks ago
    Previous Value Current Value
    Open
    Closed
  • Hille commented 3 weeks ago

    @robin Thank you, I've already tried it out yesterday and it works great! 👍

1/1
Type
Improvement
Priority
Normal
Assignee
Not assigned
Labels
No labels
Issue Votes (0)
Watchers (3)
Reference
onedev/tod#5
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover