Skip to content

Extract vMCP serve/validate logic into pkg/vmcp/cli/#4891

Merged
yrobla merged 1 commit intomainfrom
issue-4879
Apr 17, 2026
Merged

Extract vMCP serve/validate logic into pkg/vmcp/cli/#4891
yrobla merged 1 commit intomainfrom
issue-4879

Conversation

@yrobla
Copy link
Copy Markdown
Contributor

@yrobla yrobla commented Apr 16, 2026

Summary

Create the new pkg/vmcp/cli/ package with serve.go and validate.go, extracting all server-initialization and config-validation business logic from cmd/vmcp/app/commands.go into importable exported APIs (Serve, Validate) backed by package-private helpers.

This PR also performs the thin-wrap refactor originally scoped to #4880: cmd/vmcp/app/commands.go is reduced to ~130 lines of Cobra scaffolding and flag parsing, delegating entirely to pkg/vmcp/cli/. The existing loadAuthServerConfig unit test is moved from cmd/vmcp/app/ to pkg/vmcp/cli/ where the function now lives. #4880 has been closed as resolved here.

Part of #4808

Closes #4879

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Changes

File Change
pkg/vmcp/cli/serve.go New — ServeConfig + Serve() + private helpers extracted from cmd/vmcp/app/commands.go
pkg/vmcp/cli/validate.go New — ValidateConfig + Validate() entry point
pkg/vmcp/cli/auth_server_config_test.go New — loadAuthServerConfig unit tests moved from cmd/vmcp/app/
cmd/vmcp/app/commands.go Refactored — 665 → ~130 lines; all business logic removed, delegates to pkg/vmcp/cli/
cmd/vmcp/app/commands_test.go Deleted — test moved to pkg/vmcp/cli/

Does this introduce a user-facing change?

No. The standalone vmcp binary's flags, defaults, log output, and error messages are identical.

Special notes for reviewers

  • cmd/vmcp/app/commands.go duplication is fully removed in this PR (not deferred to a follow-up).
  • versions.Version (ldflag-overridable) is used consistently for version reporting in both vmcp version output and vmcpserver.Config.VersiongetVersion() has been removed.
  • The //nolint:gosec on os.ReadFile in loadAuthServerConfig has been updated to reflect the actual threat model (user-supplied local filesystem path) rather than referencing the CLI flag context.

Large PR Justification

Refactoring PR involving extraction and movement of logic. The extraction and thin-wrap are tightly coupled and cannot be meaningfully split further.

@github-actions github-actions Bot added the size/M Medium PR: 300-599 lines changed label Apr 16, 2026
@yrobla yrobla requested a review from Copilot April 16, 2026 10:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new importable pkg/vmcp/cli package that contains the extracted business logic for vmcp serve and vmcp validate, intended to be reused by both the standalone vmcp binary and future thv vmcp subcommands (per #4808 / #4879).

Changes:

  • Added pkg/vmcp/cli/serve.go implementing cli.Serve(ctx, ServeConfig) plus internal helpers for config loading, auth server config loading, backend discovery, and session factory setup.
  • Added pkg/vmcp/cli/validate.go implementing cli.Validate(ctx, ValidateConfig) to load + validate a vMCP YAML config and log a validation summary.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
pkg/vmcp/cli/serve.go New exported Serve API with extracted server initialization sequence and helper functions.
pkg/vmcp/cli/validate.go New exported Validate API with extracted config validation and summary output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/vmcp/cli/serve.go
Comment thread pkg/vmcp/cli/serve.go Outdated
Comment thread pkg/vmcp/cli/serve.go Outdated
Comment thread pkg/vmcp/cli/serve.go
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 3.75427% with 282 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.07%. Comparing base (12f25e5) to head (eac6312).
⚠️ Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
pkg/vmcp/cli/serve.go 4.45% 236 Missing ⚠️
pkg/vmcp/cli/validate.go 0.00% 28 Missing ⚠️
cmd/vmcp/app/commands.go 0.00% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4891      +/-   ##
==========================================
- Coverage   69.12%   69.07%   -0.06%     
==========================================
  Files         531      533       +2     
  Lines       55183    55195      +12     
==========================================
- Hits        38146    38126      -20     
- Misses      14113    14147      +34     
+ Partials     2924     2922       -2     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new importable pkg/vmcp/cli package that encapsulates the standalone vmcp CLI’s serve/validate business logic so it can be reused by other command entrypoints (e.g., future thv vmcp ... work) while keeping the existing binary unchanged for now.

Changes:

  • Introduces pkg/vmcp/cli/serve.go exporting Serve(ctx, ServeConfig) plus supporting helpers for config loading, backend discovery, auth server config loading, etc.
  • Introduces pkg/vmcp/cli/validate.go exporting Validate(ctx, ValidateConfig) to load + validate vMCP YAML configs and print a success summary.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/vmcp/cli/serve.go New exported serve entrypoint and extracted server initialization helpers.
pkg/vmcp/cli/validate.go New exported validate entrypoint and extracted config validation logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/vmcp/cli/serve.go Outdated
Comment thread pkg/vmcp/cli/serve.go Outdated
@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/M Medium PR: 300-599 lines changed labels Apr 16, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Large PR Detected

This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.

How to unblock this PR:

Add a section to your PR description with the following format:

## Large PR Justification

[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformation

Alternative:

Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.

See our Contributing Guidelines for more details.


This review will be automatically dismissed once you add the justification section.

@yrobla yrobla requested a review from Copilot April 16, 2026 10:42
@github-actions github-actions Bot dismissed their stale review April 16, 2026 10:44

Large PR justification has been provided. Thank you!

@github-actions
Copy link
Copy Markdown
Contributor

✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review.

@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 16, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new importable pkg/vmcp/cli package to house the vMCP serve and validate business logic, enabling reuse across the standalone vmcp binary and future thv vmcp subcommands.

Changes:

  • Added pkg/vmcp/cli/serve.go implementing Serve plus the extracted helper logic (config load/validate, backend discovery, session factory, authserver sibling config loading).
  • Added pkg/vmcp/cli/validate.go implementing Validate and success-summary logging.
  • Refactored cmd/vmcp/app/commands.go to delegate serve/validate to pkg/vmcp/cli, and adjusted a test package name to match the new package.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
pkg/vmcp/cli/serve.go New shared serve entrypoint and helpers extracted from the standalone CLI.
pkg/vmcp/cli/validate.go New shared validate entrypoint and output/logging.
pkg/vmcp/cli/auth_server_config_test.go Aligns test package to cli for testing new helpers.
cmd/vmcp/app/commands.go Now thin-wraps serve/validate over the new pkg/vmcp/cli APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/vmcp/cli/serve.go
Comment thread pkg/vmcp/cli/serve.go Outdated
Comment thread cmd/vmcp/app/commands.go
Comment thread cmd/vmcp/app/commands.go Outdated
Create pkg/vmcp/cli/ with serve.go and validate.go, extracting all
server-initialization and config-validation business logic from
cmd/vmcp/app/commands.go into importable exported APIs (Serve,
Validate). Thin-wrap cmd/vmcp/app/commands.go to delegate to the
new package, and move the existing loadAuthServerConfig test to
pkg/vmcp/cli/ where the function now lives.

Closes #4879
@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 16, 2026
@yrobla yrobla requested a review from Copilot April 16, 2026 13:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Creates a new importable pkg/vmcp/cli package to host vMCP “serve” and “validate” business logic, and updates the standalone vmcp Cobra commands to call into those new APIs.

Changes:

  • Added pkg/vmcp/cli/serve.go implementing Serve(ctx, ServeConfig) plus extracted helpers (config load/validate, backend discovery, auth server config loading, session factory creation).
  • Added pkg/vmcp/cli/validate.go implementing Validate(ctx, ValidateConfig) and preserving the existing validation + summary logging behavior.
  • Refactored cmd/vmcp/app/commands.go to delegate serve and validate command execution to pkg/vmcp/cli.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
pkg/vmcp/cli/serve.go New Serve entrypoint and extracted server initialization helpers.
pkg/vmcp/cli/validate.go New Validate entrypoint extracted from the vmcp validate command.
pkg/vmcp/cli/auth_server_config_test.go Adjusts test package to match new cli package.
cmd/vmcp/app/commands.go Removes inlined business logic and delegates to pkg/vmcp/cli; also switches version reporting to versions.Version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/vmcp/app/commands.go
Comment thread cmd/vmcp/app/commands.go
@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 16, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Large PR Detected

This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.

How to unblock this PR:

Add a section to your PR description with the following format:

## Large PR Justification

[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformation

Alternative:

Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.

See our Contributing Guidelines for more details.


This review will be automatically dismissed once you add the justification section.

@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review.

@github-actions github-actions Bot dismissed their stale review April 16, 2026 14:21

Large PR justification has been provided. Thank you!

@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Apr 16, 2026
@yrobla yrobla requested a review from Copilot April 16, 2026 14:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extracts the vMCP serve and validate business logic from the standalone cmd/vmcp/app Cobra command into a new importable package (pkg/vmcp/cli), leaving cmd/vmcp/app/commands.go as a thin flag-parsing wrapper. This aligns the vMCP CLI with the project’s thin-wrapper pattern and enables reuse by future callers.

Changes:

  • Added pkg/vmcp/cli/serve.go exposing Serve() and private helpers for server initialization.
  • Added pkg/vmcp/cli/validate.go exposing Validate() for config load + validation + summary output.
  • Moved loadAuthServerConfig unit tests into pkg/vmcp/cli/ and refactored cmd/vmcp/app/commands.go to delegate to the new package (also switching version output to versions.Version).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
pkg/vmcp/cli/serve.go New shared Serve() entry point and extracted server initialization helpers.
pkg/vmcp/cli/validate.go New shared Validate() entry point for config validation and summary logging.
pkg/vmcp/cli/auth_server_config_test.go Test moved to match new function location/package.
cmd/vmcp/app/commands.go Reduced to Cobra scaffolding + flag parsing; delegates to pkg/vmcp/cli.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yrobla yrobla merged commit 5342824 into main Apr 17, 2026
55 checks passed
@yrobla yrobla deleted the issue-4879 branch April 17, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Extra large PR: 1000+ lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract shared vMCP logic into pkg/vmcp/cli/ (serve + validate)

4 participants