Skip to content

🧪 Add MCP and RPC target implementations#63

Open
JonahSussman wants to merge 11 commits into
konveyor:mainfrom
JonahSussman:mcp-rpc-targets
Open

🧪 Add MCP and RPC target implementations#63
JonahSussman wants to merge 11 commits into
konveyor:mainfrom
JonahSussman:mcp-rpc-targets

Conversation

@JonahSussman

@JonahSussman JonahSussman commented Apr 16, 2026

Copy link
Copy Markdown

Summary

  • Add MCPConfig and MCP target type for connecting to analyzer-mcp servers (stdio and HTTP modes)
  • Implement MCPTarget.Execute() with MCP protocol (connects via go-sdk, calls analyze tool, parses rulesets)
  • Implement KaiRPCTarget.Execute() for connecting to kai-analyzer-rpc servers via rpc2
  • Fix pre-existing broken tests in kantra_test.go and tackle_hub_test.go (Rules field changed from []string to []CustomRule but tests were never updated)
  • Add go test to premerge CI workflow so unit test breakage is caught before merge
  • Add mcp to CLI help text for -t flag

Test plan

  • All existing tests pass
  • New MCP constructor, factory, and Execute tests pass
  • KaiRPC constructor, Execute, and buildRPCAnalyzeArgs tests pass
  • go test ./... passes across all packages

Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
@coderabbitai

coderabbitai Bot commented Apr 16, 2026

Copy link
Copy Markdown

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR introduces support for MCP analyzer targets as an alternative to existing analyzers (kantra, tackle-hub, vscode, etc.). It adds MCP configuration schema, factory-pattern support, a new MCPTarget implementation, and updates rule handling from simple strings to structured CustomRule types with Git/File distinction. CI workflow enhanced with unit test job; dependencies bumped.

Changes

Cohort / File(s) Summary
CI/CD Setup
.github/workflows/permerge-ci.yaml
Added new unit-test job to run go test -short -timeout 5m on Ubuntu; checks out code and configures Go via go.mod.
Dependency Management
go.mod
Updated indirect dependencies: github.com/golang-jwt/jwt/v5 (v5.2.2→v5.3.1) and golang.org/x/sys (v0.31.0→v0.41.0).
Configuration Schema
pkg/config/target_config.go
Extended TargetConfig.Type validation to include "mcp" option. Added optional MCP field. Introduced new MCPConfig struct with BinaryPath, ProviderConfig, Rules, Endpoint, and Token fields for MCP server configuration.
Factory Pattern
pkg/targets/factory.go
Added case "mcp" branch to NewTarget to instantiate MCP targets via NewMCPTarget(cfg.MCP).
MCP Target Implementation
pkg/targets/mcp.go
New file introducing MCPTarget struct and NewMCPTarget() constructor. Validates configuration (requires exactly one of BinaryPath or Endpoint). Implements Name() returning "mcp" and Execute() method (returns "not yet implemented" error).
MCP Tests
pkg/targets/mcp_test.go, pkg/targets/factory_test.go
Added comprehensive table-driven tests for MCP target creation validation, mutual exclusivity checks, and name verification. Extended factory tests to cover MCP type alongside existing target types.
Rule Handling Refactoring
pkg/targets/kantra_test.go, pkg/targets/tackle_hub_test.go
Migrated AnalysisConfig.Rules from []string to structured []config.CustomRule with Git and File variants. Updated test logic to decompose rules by type and validate git/file components accordingly; removed reliance on RulesGitComponents and ParseGitURLs() in favor of direct rule inspection.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A new protocol arrives at our door,
With configurations structured and more,
MCP targets branch like paths in the wood,
While rules take new shapes, as they should.
Factory patterns dance with delight,
Tests keep the logic true and right! 🎯

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title mentions 'MCP and RPC target implementations' but the PR primarily adds MCP target support; KaiRPC Execute implementation is noted but the title says 'implementations' suggesting both are fully implemented when KaiRPC.Execute() is still pending. Clarify title to reflect actual scope: either 'Add MCP target support' or 'Add MCP and KaiRPC target scaffolding' depending on implementation completeness.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@JonahSussman JonahSussman changed the title Add MCP and KaiRPC target implementations 🧪 Add MCP and RPC target implementations Apr 16, 2026
@JonahSussman

Copy link
Copy Markdown
Author

@coderabbitai pause

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/config/target_config.go (1)

1-154: ⚠️ Potential issue | 🔴 Critical

Critical: pkg/config package no longer compiles — git_url_test.go was not migrated to []CustomRule.

The test file pkg/config/git_url_test.go has compilation errors that prevent the entire repository from building:

  • Lines 127, 144, 155: Rules field initialized with []string{…} but now expects []CustomRule with either {File: &config.FilePathRule{FilePath: "…"}} for local paths or {Git: &config.GitRepoRule{GitRepo: "…"}} for Git repositories.

  • Lines 195–197: References to ac.RulesGitComponents which no longer exists. The AnalysisConfig struct only has ApplicationGitComponents; rule parsing is not implemented in the current ParseGitURLs() method.

Migrate using the same pattern applied to pkg/targets/kantra_test.go and pkg/targets/tackle_hub_test.go.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/config/target_config.go` around lines 1 - 154, The test git_url_test.go
fails because the AnalysisConfig.Rules field is still being initialized as
[]string but the code now expects []CustomRule; update the test to construct
rules as []config.CustomRule using File: &config.FilePathRule{FilePath: "..."}
for local paths and Git: &config.GitRepoRule{GitRepo: "..."} for git entries
(mirror the pattern used in pkg/targets/kantra_test.go and
pkg/targets/tackle_hub_test.go). Also remove or replace any uses of
ac.RulesGitComponents (e.g., lines referencing RulesGitComponents) to use the
current fields — use ac.ApplicationGitComponents where appropriate and ensure
ParseGitURLs() is exercised against ApplicationGitComponents or adapted to parse
rules if you add rule parsing. Update git_url_test.go so all Rules
initializations and assertions match the new CustomRule types and existing
ParseGitURLs()/ApplicationGitComponents API.
🧹 Nitpick comments (5)
.github/workflows/permerge-ci.yaml (1)

14-22: Consider enabling Go module caching to speed up the job.

actions/setup-go@v5 enables module/build caching by default, but it keys off go.sum. Since this repo has a go.sum at root that should work out of the box — just worth confirming the cache hits show up in the Actions run, otherwise add cache: true explicitly. No behavior change needed otherwise.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/permerge-ci.yaml around lines 14 - 22, The unit-test
workflow currently uses actions/setup-go@v5 but doesn't explicitly enable module
caching; update the unit-test job to ensure Go module cache is enabled (either
confirm that the existing go.sum is used or set cache: true on the
actions/setup-go@v5 step) so dependencies are cached across runs and the Run
unit tests step (go test -short -timeout 5m ./...) benefits from faster setup.
pkg/targets/tackle_hub_test.go (1)

691-691: Pre-existing typo: GetCompents should be GetComponents.

Not introduced by this PR (it's defined on GitRepoRule in pkg/config/types.go), but since this PR is the first place new code is calling it and kantra_test.go picks it up too, it may be a good moment to rename the method in a follow-up. Purely cosmetic — no behavior change.

Also applies to: 707-707

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/targets/tackle_hub_test.go` at line 691, Rename the misspelled method
GetCompents to GetComponents on the GitRepoRule type and update all call sites
(e.g., the call in the tests referencing analysis.Rules[0].Git.GetCompents and
the occurrences in kantra_test.go) to use GetComponents; ensure you update the
method declaration in the GitRepoRule type (pkg/config/types.go), any
implementing types or interfaces, and imports/uses so the compiler sees the new
name everywhere.
pkg/config/target_config.go (2)

125-132: Document stdio/http mutual exclusivity and consider secret handling for Token.

Two things:

  1. The mutual-exclusivity/required rules between BinaryPath and Endpoint are enforced in NewMCPTarget (per pkg/targets/mcp_test.go) but are not reflected in struct validate: tags or in this comment. Either add a brief doc comment describing the two modes (stdio via BinaryPath/ProviderConfig/Rules vs http via Endpoint/Token) or use validator's required_without/excluded_with tags so LoadTargetConfig catches misconfiguration consistently with other config types.
  2. Token is read from plain YAML on disk. Consider supporting env-var substitution (or documenting that callers should expand env vars before loading) so users can avoid committing tokens, matching how TackleHubConfig.Token is already used.
📝 Suggested doc comment
-// MCPConfig for MCP analyzer server
+// MCPConfig for MCP analyzer server.
+//
+// Two transport modes are supported and are mutually exclusive:
+//   - stdio: set BinaryPath (plus optional ProviderConfig and Rules) to spawn
+//     a local analyzer-mcp process.
+//   - http:  set Endpoint (plus optional Token) to connect to a remote
+//     analyzer-mcp server.
 type MCPConfig struct {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/config/target_config.go` around lines 125 - 132, The MCPConfig struct
lacks documentation and validation for the mutually-exclusive stdio vs http
modes and doesn't handle secret Tokens securely; update the MCPConfig definition
to (a) add a brief doc comment explaining the two modes — stdio mode using
BinaryPath/ProviderConfig/Rules and http mode using Endpoint/Token — and note
that BinaryPath and Endpoint are mutually exclusive and one is required, and (b)
add validator tags (e.g. required_without/excluded_with equivalents) on
BinaryPath and Endpoint so LoadTargetConfig rejects invalid combos consistent
with NewMCPTarget behavior; additionally, add support or a note for env-var
substitution for Token (like TackleHubConfig.Token uses) so secrets are not
stored directly in YAML or document that callers must expand env vars before
loading.

129-129: Rules here is a single path string; consider renaming or clarifying to avoid confusion with AnalysisConfig.Rules.

AnalysisConfig.Rules is now []CustomRule (mix of git and file rules) after this PR. MCPConfig.Rules is a single path forwarded to the MCP server. Users reading YAML will likely be confused that the same key name has a completely different shape in two different contexts. Consider RulesPath string (or similar) for clarity.

♻️ Suggested rename
-	Rules          string `yaml:"rules,omitempty"`
+	RulesPath      string `yaml:"rulesPath,omitempty"`

Update callers in pkg/targets/mcp.go, pkg/targets/mcp_test.go, and pkg/targets/factory_test.go accordingly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/config/target_config.go` at line 129, The struct field Rules in
pkg/config/target_config.go is a single path string but shares the same key name
as AnalysisConfig.Rules (which is now []CustomRule), causing confusion; rename
the field to a clearer name like RulesPath (or RulesFile/RulesURI) and update
all callers that reference MCPConfig.Rules — notably pkg/targets/mcp.go,
pkg/targets/mcp_test.go, and pkg/targets/factory_test.go — to use the new field
name and the YAML tag (e.g., `yaml:"rules_path,omitempty"`) so the schema and
code remain consistent.
pkg/targets/mcp_test.go (1)

9-83: Good constructor coverage; consider adding endpoint URL validation cases.

The table covers nil, missing, mutex, and both happy paths well. A couple of optional additions worth considering as you flesh out Execute():

  • Invalid/malformed Endpoint (e.g. "not-a-url", missing scheme) — useful once Execute() actually dials the endpoint, to fail fast at construction.
  • ProviderConfig or Rules set without BinaryPath — arguably a misconfiguration (these fields only make sense for stdio mode).
  • Token set without Endpoint — similar rationale (http-only field).

Not blocking; just flagging before the Execute() implementation lands so the validation surface is locked in.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/targets/mcp_test.go` around lines 9 - 83, Add tests and constructor
validation for additional misconfigurations: extend TestNewMCPTarget table to
include malformed Endpoint values (e.g. "not-a-url" or missing scheme) and
assert NewMCPTarget returns an error; add cases where ProviderConfig or Rules
are set while BinaryPath is empty and assert an error; add a case where Token is
set but Endpoint is empty and assert an error. Implement corresponding
validation in NewMCPTarget (inspect cfg.Endpoint with URL parsing, check that
ProviderConfig/Rules require BinaryPath, and that Token requires Endpoint) so
these test cases fail fast during construction rather than at Execute().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/permerge-ci.yaml:
- Line 22: Tests in pkg/config/git_url_test.go are failing to compile because
they still construct Rules as []string and reference the removed
AnalysisConfig.RulesGitComponents field; update those tests to use the new
[]CustomRule type and remove or replace any usage of RulesGitComponents.
Specifically, change test fixtures and helper functions that build Rules to
return []CustomRule (matching the CustomRule struct/constructor in
target_config.go) and remove references to AnalysisConfig.RulesGitComponents,
replacing them with the current field or API described in target_config.go
(adjust test assertions and setup accordingly). Ensure imports and any
conversions are updated so go test ./... compiles cleanly.

In `@pkg/targets/mcp.go`:
- Line 14: MCPTarget.rules is still defined as a plain string while the codebase
now uses []CustomRule; update the type for MCPTarget.rules and the underlying
MCPConfig.Rules to []CustomRule so they match the new schema and can accept
Git-sourced rule definitions, adjust any constructors/parsers that populate
MCPConfig (look for functions that build MCPConfig or MCPTarget) to
parse/deserialize rule entries into []CustomRule, and ensure the
MCPTarget.Execute method (when implemented) can consume the new []CustomRule
field without further changes.

---

Outside diff comments:
In `@pkg/config/target_config.go`:
- Around line 1-154: The test git_url_test.go fails because the
AnalysisConfig.Rules field is still being initialized as []string but the code
now expects []CustomRule; update the test to construct rules as
[]config.CustomRule using File: &config.FilePathRule{FilePath: "..."} for local
paths and Git: &config.GitRepoRule{GitRepo: "..."} for git entries (mirror the
pattern used in pkg/targets/kantra_test.go and pkg/targets/tackle_hub_test.go).
Also remove or replace any uses of ac.RulesGitComponents (e.g., lines
referencing RulesGitComponents) to use the current fields — use
ac.ApplicationGitComponents where appropriate and ensure ParseGitURLs() is
exercised against ApplicationGitComponents or adapted to parse rules if you add
rule parsing. Update git_url_test.go so all Rules initializations and assertions
match the new CustomRule types and existing
ParseGitURLs()/ApplicationGitComponents API.

---

Nitpick comments:
In @.github/workflows/permerge-ci.yaml:
- Around line 14-22: The unit-test workflow currently uses actions/setup-go@v5
but doesn't explicitly enable module caching; update the unit-test job to ensure
Go module cache is enabled (either confirm that the existing go.sum is used or
set cache: true on the actions/setup-go@v5 step) so dependencies are cached
across runs and the Run unit tests step (go test -short -timeout 5m ./...)
benefits from faster setup.

In `@pkg/config/target_config.go`:
- Around line 125-132: The MCPConfig struct lacks documentation and validation
for the mutually-exclusive stdio vs http modes and doesn't handle secret Tokens
securely; update the MCPConfig definition to (a) add a brief doc comment
explaining the two modes — stdio mode using BinaryPath/ProviderConfig/Rules and
http mode using Endpoint/Token — and note that BinaryPath and Endpoint are
mutually exclusive and one is required, and (b) add validator tags (e.g.
required_without/excluded_with equivalents) on BinaryPath and Endpoint so
LoadTargetConfig rejects invalid combos consistent with NewMCPTarget behavior;
additionally, add support or a note for env-var substitution for Token (like
TackleHubConfig.Token uses) so secrets are not stored directly in YAML or
document that callers must expand env vars before loading.
- Line 129: The struct field Rules in pkg/config/target_config.go is a single
path string but shares the same key name as AnalysisConfig.Rules (which is now
[]CustomRule), causing confusion; rename the field to a clearer name like
RulesPath (or RulesFile/RulesURI) and update all callers that reference
MCPConfig.Rules — notably pkg/targets/mcp.go, pkg/targets/mcp_test.go, and
pkg/targets/factory_test.go — to use the new field name and the YAML tag (e.g.,
`yaml:"rules_path,omitempty"`) so the schema and code remain consistent.

In `@pkg/targets/mcp_test.go`:
- Around line 9-83: Add tests and constructor validation for additional
misconfigurations: extend TestNewMCPTarget table to include malformed Endpoint
values (e.g. "not-a-url" or missing scheme) and assert NewMCPTarget returns an
error; add cases where ProviderConfig or Rules are set while BinaryPath is empty
and assert an error; add a case where Token is set but Endpoint is empty and
assert an error. Implement corresponding validation in NewMCPTarget (inspect
cfg.Endpoint with URL parsing, check that ProviderConfig/Rules require
BinaryPath, and that Token requires Endpoint) so these test cases fail fast
during construction rather than at Execute().

In `@pkg/targets/tackle_hub_test.go`:
- Line 691: Rename the misspelled method GetCompents to GetComponents on the
GitRepoRule type and update all call sites (e.g., the call in the tests
referencing analysis.Rules[0].Git.GetCompents and the occurrences in
kantra_test.go) to use GetComponents; ensure you update the method declaration
in the GitRepoRule type (pkg/config/types.go), any implementing types or
interfaces, and imports/uses so the compiler sees the new name everywhere.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5ddc8c3d-8187-4e7d-858d-20dab1b5076e

📥 Commits

Reviewing files that changed from the base of the PR and between 930fd83 and df1cbe2.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (9)
  • .github/workflows/permerge-ci.yaml
  • go.mod
  • pkg/config/target_config.go
  • pkg/targets/factory.go
  • pkg/targets/factory_test.go
  • pkg/targets/kantra_test.go
  • pkg/targets/mcp.go
  • pkg/targets/mcp_test.go
  • pkg/targets/tackle_hub_test.go

Comment thread .github/workflows/permerge-ci.yaml
Comment thread pkg/targets/mcp.go
type MCPTarget struct {
binaryPath string
providerConfig string
rules string

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

rules field type inconsistent with the CustomRule refactor.

This PR migrates rule handling from []string to []CustomRule elsewhere in the codebase, but MCPTarget.rules (and the underlying MCPConfig.Rules in pkg/config/target_config.go) are still plain string. When Execute is implemented, it will not be able to consume Git-sourced rule definitions the way other targets now do. Consider aligning the schema/field with []CustomRule before the Execute implementation lands, to avoid a breaking config change later.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/targets/mcp.go` at line 14, MCPTarget.rules is still defined as a plain
string while the codebase now uses []CustomRule; update the type for
MCPTarget.rules and the underlying MCPConfig.Rules to []CustomRule so they match
the new schema and can accept Git-sourced rule definitions, adjust any
constructors/parsers that populate MCPConfig (look for functions that build
MCPConfig or MCPTarget) to parse/deserialize rule entries into []CustomRule, and
ensure the MCPTarget.Execute method (when implemented) can consume the new
[]CustomRule field without further changes.

@coderabbitai

coderabbitai Bot commented Apr 16, 2026

Copy link
Copy Markdown
✅ Actions performed

Reviews paused.

Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
Signed-off-by: JonahSussman <sussmanjonah@gmail.com>
Signed-off-by: JonahSussman <sussmanjonah@gmail.com>

@shawn-hurley shawn-hurley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should the MCP server expose every violation and insight to the LLM?

Many informational/tagging incidents will cause noise and be unactionable.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants