Skip to content

feat(go-api): migrate MCP server detail and download API to Go - #16113

Merged
JinHai-CN merged 2 commits into
infiniflow:mainfrom
Harry-Hz-Zhang:feat-mcp-mcpid-get-upstream
Jun 18, 2026
Merged

JinHai-CN merged 2 commits into
infiniflow:mainfrom
Harry-Hz-Zhang:feat-mcp-mcpid-get-upstream

Conversation

@Harry-Hz-Zhang

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

  • Migrated MCP server detail and export (download) API from Python to Go.
  • Registered route: GET /api/v1/mcp/servers/:mcp_id (supporting ?mode=download query parameter).

How to Test

  • Unit Tests: Run the following commands to verify date formatting, pagination, and export schema:
go test -v ./internal/handler -run "TestMCP|TestNewMCPServer"
go test -v ./internal/service -run "MCP"
  • Manual Verification: Compared the JSON outputs of curl requests between Python (port 9380) and Go (port 9384) for /api/v1/mcp/servers/<mcp_id> in both normal and download mode to ensure 100% key-value parity.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 17, 2026
@Harry-Hz-Zhang Harry-Hz-Zhang added the ci Continue Integration label Jun 17, 2026
@coderabbitai

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e310c301-1b36-4399-a52b-eba52fe9ccf2

📥 Commits

Reviewing files that changed from the base of the PR and between 10be5a0 and 8190379.

📒 Files selected for processing (1)
  • internal/router/router.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/router/router.go

📝 Walkthrough

Walkthrough

Adds a GET /api/v1/mcp/servers/:mcp_id endpoint across the service, handler, and router layers. The service gains GetMCPServer (tenant-scoped lookup) and ExportMCPServer (serialises server config into a named map with authorization_token and tools). The handler branches on mode=download, and a shared mcpDetailError helper normalises all error responses to HTTP 200.

Changes

MCP Server GET Endpoint

Layer / File(s) Summary
Service types and retrieval/export logic
internal/service/mcp.go, internal/service/mcp_test.go
Adds ExportMCPServer and ExportMCPServerResponse types; implements GetMCPServer (not-found mapped to data error), ExportMCPServer, and newExportMCPServerResponse (nil-safe extraction of authorization_token and tools from Variables); two unit tests verify the full export shape and the empty-variables defaults.
Handler, error helper, and tests
internal/handler/mcp.go, internal/handler/mcp_test.go
Adds MCPHandler.GetMCPServer (auth → mcp_id param → download-mode branch); adds mcpDetailError (always HTTP 200, CodeDataError preserved, others mapped to CodeExceptionError with data: nil); test asserts data field is absent from CodeDataError responses.
Router wiring
internal/router/router.go
Registers GET /api/v1/mcp/servers/:mcp_id to MCPHandler.GetMCPServer; surrounding commit-route block is reformatted without functional change.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Router
  participant GetMCPServer
  participant MCPService
  participant DAO

  Client->>Router: GET /api/v1/mcp/servers/:mcp_id[?mode=download]
  Router->>GetMCPServer: dispatch
  GetMCPServer->>GetMCPServer: authenticate user, extract mcp_id
  alt mode == download
    GetMCPServer->>MCPService: ExportMCPServer(userID, mcpID)
    MCPService->>DAO: GetMCPServer(tenantID, mcpID)
    DAO-->>MCPService: entity.MCPServer
    MCPService-->>GetMCPServer: ExportMCPServerResponse
    GetMCPServer-->>Client: HTTP 200 + export JSON
  else default
    GetMCPServer->>MCPService: GetMCPServer(tenantID, mcpID)
    MCPService->>DAO: GetMCPServer(tenantID, mcpID)
    DAO-->>MCPService: entity.MCPServer or not-found
    MCPService-->>GetMCPServer: MCPServer or CodeDataError
    GetMCPServer-->>Client: HTTP 200 + MCPServer JSON
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐇 Hippity hop, a new route appears,
A server by ID now magically clears.
Download mode exports, tools tucked inside,
data: nil omitted — with Python-side pride.
The rabbit has wired the MCP with glee,
GET /mcp/servers/:id — come find me! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: migrating the MCP server detail and download API from Python to Go, which aligns with the changeset modifications across handler, service, router, and test files.
Description check ✅ Passed The PR description includes the problem being solved and testing instructions, but does not explicitly mark the 'Type of change' section required by the template, though the context clearly indicates this is a feature migration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@Harry-Hz-Zhang
Harry-Hz-Zhang marked this pull request as draft June 17, 2026 01:48
@Harry-Hz-Zhang
Harry-Hz-Zhang marked this pull request as ready for review June 17, 2026 01:48
@Harry-Hz-Zhang Harry-Hz-Zhang changed the title feat: mcp_id get feat(go-api): migrate MCP server detail and download API to Go Jun 17, 2026
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (6865039) to head (8190379).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16113      +/-   ##
==========================================
- Coverage   94.56%   93.16%   -1.40%     
==========================================
  Files          10       10              
  Lines         717      717              
  Branches      118      118              
==========================================
- Hits          678      668      -10     
- Misses         25       29       +4     
- Partials       14       20       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xugangqiang

Copy link
Copy Markdown
Contributor

LGTM

@JinHai-CN
JinHai-CN merged commit 69dbc44 into infiniflow:main Jun 18, 2026
1 check passed
@coderabbitai coderabbitai Bot mentioned this pull request Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants