Skip to content

feat(mcp-server): Align MCP Tools with Kestra Workflow#13

Merged
crypticsaiyan merged 2 commits into
devfrom
feat/cline-mcp-server
Dec 14, 2025
Merged

feat(mcp-server): Align MCP Tools with Kestra Workflow#13
crypticsaiyan merged 2 commits into
devfrom
feat/cline-mcp-server

Conversation

@crypticsaiyan

@crypticsaiyan crypticsaiyan commented Dec 14, 2025

Copy link
Copy Markdown
Owner

Description

Align the InFoundry MCP server with the Kestra workflow pipeline, ensuring exactly 9 tools that mirror the end-to-end orchestration steps. This refactoring provides a complete, working automation toolkit for Cline CLI users to generate cloud infrastructure.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📚 Documentation update
  • 🔧 Configuration change
  • ♻️ Refactor (no functional changes)
  • 🏗️ Infrastructure/IaC change

Changes Made

  • Refactor MCP server to exactly 9 tools matching Kestra pipeline:
    • ingest_repo - Analyze repository (supports GitHub URLs)
    • ingest_telemetry - Collect service metrics
    • propose_architecture - AI architecture proposal via Oumi
    • render_graph - Convert architecture to React Flow graph
    • generate_iac - Generate Terraform (proper multi-line HCL format)
    • validate_iac - Terraform validation
    • create_pr - GitHub PR creation with labels
    • validate_pr - Check PR status and reviews
    • evaluate - AI evaluation of deployment results
  • Fix Oumi API call to use correct /v1/chat/completions endpoint
  • Add mcp.json.example for Cline CLI configuration
  • Add test-all-tools.mjs for testing all 9 workflow steps
  • Add scripts/generate-pr.sh - CLI tool to generate PR descriptions using Cline
  • Update Kestra 07-create-pr.yaml to support labels
  • Remove non-functional cline-architect.yml workflow

Infrastructure Changes (if applicable)

  • Terraform files modified
  • New cloud resources added
  • Security groups/IAM policies changed
  • Cost impact assessed

IaC Details

Terraform templates now generate proper multi-line HCL format without semicolons.

Testing

  • Unit tests pass
  • Integration tests pass
  • Manual testing completed
  • IaC validation (terraform validate) passes

Test Evidence

All 9 MCP tools tested successfully via test-all-tools.mjs

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix/feature works
  • New and existing unit tests pass locally
  • Any dependent changes have been merged and published

CodeRabbit Review

  • I have addressed all CodeRabbit suggestions
  • Critical security/performance issues resolved
  • IaC best practices followed (for infrastructure changes)

This PR will be automatically reviewed by CodeRabbit 🐰

Summary by CodeRabbit

  • New Features

    • Enhanced workflow with 9-step architecture pipeline for the MCP server
    • Added automated PR generation and labeling capabilities
    • Introduced PR validation and evaluation tools
  • Documentation

    • Updated README with step-by-step workflow guide and environment variable setup
    • Added example MCP configuration file
  • Tests

    • Added end-to-end test script for workflow validation
  • Chores

    • Removed GitHub Actions automation workflow

✏️ Tip: You can customize this high-level summary in your review settings.

…generation

- Refactor MCP server to exactly 9 tools matching Kestra pipeline:
  ingest_repo, ingest_telemetry, propose_architecture, render_graph,
  generate_iac, validate_iac, create_pr, validate_pr, evaluate
- Fix Terraform templates to use proper multi-line HCL format (no semicolons)
- Fix create_pr to accept both JSON string and object for files param
- Fix Oumi API call to use correct /v1/chat/completions endpoint
- Add ingest_repo support for GitHub URLs (auto-clone)
- Add mcp.json.example for Cline configuration
- Add test-all-tools.mjs for testing all 9 workflow steps
- Remove non-functional cline-architect.yml workflow
- Update README with 9-step workflow documentation
@coderabbitai

coderabbitai Bot commented Dec 14, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This PR replaces a monolithic GitHub Actions workflow (cline-architect.yml) with a modular, 9-step architecture analysis and IaC generation pipeline. The new approach refactors the MCP server tools into discrete, composable steps—from repository ingestion and telemetry collection through architecture proposal, graph rendering, Terraform generation, validation, and PR creation—along with supporting test automation and orchestration enhancements.

Changes

Cohort / File(s) Change Summary
Workflow Removal
​.github/workflows/cline-architect.yml
Removed the entire GitHub Actions workflow that automated Cline-based architecture analysis, IaC generation, and PR creation from GitHub issues.
MCP Server Tool Redesign
infoundry-mcp-server/src/index.ts
Completely refactored 9 workflow tools: renamed analyze_repo to ingest_repo (adds GitHub URL support), added ingest_telemetry, expanded propose_architecture (Oumi model + fallback heuristics), added render_graph, generate_iac, validate_iac, create_pr, validate_pr, and evaluate.
MCP Documentation & Configuration
infoundry-mcp-server/README.md, infoundry-mcp-server/mcp.json.example
Updated README to reflect 9-step workflow with example commands, environment variables table, and testing instructions. Added mcp.json.example with sample infoundry-architect server configuration.
Testing & Orchestration
infoundry-mcp-server/test-all-tools.mjs, orchestrator/kestra_pipelines/07-create-pr.yaml
New end-to-end test harness exercising all 9 MCP tools via JSON-RPC. Enhanced Kestra PR creation pipeline with labels input and GitHub API labeling logic.
PR Generation Script
scripts/generate-pr.sh
New Bash script that generates PR descriptions using Cline CLI, collecting commit metadata and diff stats, with fallback skeleton on Cline failure.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client/Orchestrator
    participant MCP as MCP Server
    participant GitHub as GitHub API
    participant Oumi as Oumi Model
    participant TF as Terraform
    
    Client->>MCP: ingest_repo(local path or GitHub URL)
    MCP->>GitHub: Clone repo (if URL)
    MCP-->>Client: Service profiles + metadata
    
    Client->>MCP: ingest_telemetry(services, metrics)
    MCP-->>Client: Telemetry summary per service
    
    Client->>MCP: propose_architecture(serviceProfile, telemetry, cloudProvider)
    MCP->>Oumi: Query model endpoint
    alt Model available
        Oumi-->>MCP: Architecture proposal
    else Fallback
        MCP-->>MCP: Heuristic generation
    end
    MCP-->>Client: Architecture plan + metadata
    
    Client->>MCP: render_graph(architecturePlan)
    MCP-->>Client: React Flow nodes, edges, styling
    
    Client->>MCP: generate_iac(graph, cloudProvider, projectName)
    MCP-->>Client: main.tf, variables.tf, metadata
    
    Client->>MCP: validate_iac(iacDir)
    MCP->>TF: fmt, init, validate, tflint
    TF-->>MCP: Validation results
    MCP-->>Client: Per-check results + overall validity
    
    Client->>MCP: create_pr(repository, files, targetFolder, baseBranch, labels)
    MCP->>GitHub: Create branch & commit files
    MCP->>GitHub: Create PR with labels
    GitHub-->>MCP: PR created
    MCP-->>Client: PR metadata
    
    Client->>MCP: validate_pr(repository, prNumber)
    MCP->>GitHub: Fetch PR status, CI checks, reviews
    GitHub-->>MCP: PR status + checks
    MCP-->>Client: Merge readiness assessment
    
    Client->>MCP: evaluate(deployResult)
    MCP-->>Client: Score, recommendations, feedback
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Areas requiring extra attention:

  • MCP server tool refactor (infoundry-mcp-server/src/index.ts): Major signature and behavioral changes across 9 tools; verify fallback heuristics for propose_architecture, Terraform validation chain correctness, and GitHub API interactions in create_pr and validate_pr.
  • Workflow removal implications: Ensure no CI/CD dependencies or automation triggers depend on the deleted .github/workflows/cline-architect.yml; confirm migration path to Kestra pipelines is complete.
  • PR generation script (scripts/generate-pr.sh): Verify Cline CLI invocation, fallback PR skeleton adequacy, and cleanup of temporary context files.
  • Kestra pipeline changes: Check that labels input parsing and GitHub API labeling succeed without token/API errors.

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly describes the main refactoring: aligning MCP tools with the Kestra workflow pipeline, which is the core change across multiple files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/cline-mcp-server

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

@github-actions

github-actions Bot commented Dec 14, 2025

Copy link
Copy Markdown

🐰 CodeRabbit Review Reminder

This PR will be automatically reviewed by CodeRabbit. Please ensure:

  • All CodeRabbit suggestions have been addressed
  • Critical issues are resolved before requesting human review
  • IaC changes follow security best practices

Tip: Reply to CodeRabbit comments with @coderabbitai to get clarifications or request re-reviews.


Maintainer approval is required after addressing CodeRabbit feedback.

@coderabbitai

coderabbitai Bot commented Dec 14, 2025

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@github-actions Thanks for the reminder! 👋

Hey there! I'm CodeRabbit, ready to help out with this PR whenever you need me. I see this is a pretty substantial feature addition that aligns your MCP server with the Kestra workflow pipeline - 9 tools covering the full orchestration flow from repo ingestion to deployment evaluation. That's a solid architecture!

I'm here and available to:

  • Review the changes when requested
  • Answer questions about the code
  • Provide suggestions for improvements
  • Help validate your IaC changes
  • Clarify any concerns that come up

Just tag me with @coderabbitai followed by your request (like "review the changes" or questions about specific parts of the code), and I'll jump right in! I'm particularly good at catching issues in TypeScript, Terraform, and workflow configurations, which seems perfect for this PR.

Looking forward to helping you get this merged! 🚀

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

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

⚠️ Outside diff range comments (2)
infoundry-mcp-server/src/index.ts (1)

419-574: Critical: Step 5 generates Terraform that likely can’t pass terraform validate.
Examples: aws_lambda_function is missing required args (like filename/s3_*/image_uri) and references aws_iam_role.lambda that doesn’t exist; ALB + RDS typically need more required wiring (SGs/subnets/subnet group), etc. This makes Step 6 “validate_iac” kind of doomed.

Actionable direction: either (A) generate a minimal but valid AWS baseline (default VPC + SG + subnet sources + IAM roles) or (B) change validate_iac to “lint only / best-effort” and document it as such. Right now the tool contract says “Validate Terraform”, so I’d strongly lean (A).

infoundry-mcp-server/README.md (1)

26-39: Doc nit: config example doesn’t mention passing GITHUB_TOKEN into the MCP server.
Given create_pr needs it, add a short note pointing to mcp.json.example (or show env in the snippet).

Also applies to: 54-60

🧹 Nitpick comments (5)
infoundry-mcp-server/src/index.ts (4)

30-52: validatePath() is a solid start, but it’s too strict for “outputDir” use-cases.
Right now it requires the path to already exist + be a directory, so you can’t reuse it for “create this output dir” scenarios (like Step 5). Consider splitting into validateExistingDir() vs validateSafePathString() so Step 5 can safely create dirs.


54-159: Step 1 portability: find/rm makes ingest_repo basically Unix-only.
If someone runs this MCP server on Windows, Step 1 cleanup + discovery will break. Prefer doing traversal + delete via Node (fs.promises, fs.rmSync(..., { recursive:true }), or a tiny glob lib).

-        spawnSync('rm', ['-rf', tempDir], { timeout: 10000 });
+        fs.rmSync(tempDir, { recursive: true, force: true });

161-203: Step 2: treat metricsJson as untrusted input (schema it).
JSON.parse(metricsJson) accepts anything; if downstream assumes fields exist, you’ll get weird runtime behavior. Zod-parse the parsed object into a known shape (even if optional fields).


303-418: Step 4: good structure; small perf/readability win by hoisting STYLES/EDGES.
They’re recreated every call; moving them to module scope simplifies diffs and saves a little work.

orchestrator/kestra_pipelines/07-create-pr.yaml (1)

29-34: Label support looks good; consider surfacing label add failures in output JSON too.
Right now you print a warning, but result["status"] stays “created” even if labels fail. Might be fine, but adding something like result["labels_applied"]=true/false would help automation.

Also applies to: 53-68, 150-157

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 521d00c and e4f34b4.

📒 Files selected for processing (7)
  • .github/workflows/cline-architect.yml (0 hunks)
  • infoundry-mcp-server/README.md (2 hunks)
  • infoundry-mcp-server/mcp.json.example (1 hunks)
  • infoundry-mcp-server/src/index.ts (4 hunks)
  • infoundry-mcp-server/test-all-tools.mjs (1 hunks)
  • orchestrator/kestra_pipelines/07-create-pr.yaml (5 hunks)
  • scripts/generate-pr.sh (1 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/cline-architect.yml
🧰 Additional context used
📓 Path-based instructions (1)
**/*.md

⚙️ CodeRabbit configuration file

Do not emphasize these files too much

Files:

  • infoundry-mcp-server/README.md
🧬 Code graph analysis (1)
infoundry-mcp-server/src/index.ts (2)
infoundry-mcp-server/test-all-tools.mjs (2)
  • server (15-18)
  • graph (89-92)
infoundry-mcp-server/test.mjs (1)
  • server (18-21)
🪛 Shellcheck (0.11.0)
scripts/generate-pr.sh

[warning] 9-9: OUTPUT_FILE appears unused. Verify use (or export if used externally).

(SC2034)

🔇 Additional comments (1)
infoundry-mcp-server/src/index.ts (1)

815-878: Step 9 scoring logic is reasonable for a first pass.
Nice: it degrades gracefully if tflint is skipped, and it gives concrete next actions.

Comment thread infoundry-mcp-server/mcp.json.example
Comment thread infoundry-mcp-server/src/index.ts
Comment thread infoundry-mcp-server/src/index.ts
Comment thread infoundry-mcp-server/src/index.ts
Comment thread infoundry-mcp-server/src/index.ts
Comment thread infoundry-mcp-server/test-all-tools.mjs
Comment thread scripts/generate-pr.sh
@crypticsaiyan crypticsaiyan merged commit df9a096 into dev Dec 14, 2025
18 checks passed
@crypticsaiyan crypticsaiyan deleted the feat/cline-mcp-server branch December 14, 2025 09:51
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.

1 participant