Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat (mcp): add the helm_template tool call to the MCP server to render manifests#39

Merged
KaranJagtiani merged 1 commit intoskyflo-ai:mainfrom
Sachin-chaurasiya:feature/25-helm_template
Oct 8, 2025
Merged

feat (mcp): add the helm_template tool call to the MCP server to render manifests#39
KaranJagtiani merged 1 commit intoskyflo-ai:mainfrom
Sachin-chaurasiya:feature/25-helm_template

Conversation

@Sachin-chaurasiya
Copy link
Copy Markdown
Contributor

@Sachin-chaurasiya Sachin-chaurasiya commented Oct 4, 2025

Description

Please include a summary of the changes and which issue is fixed. Explain the motivation for the changes.

Implement the read-only Helm rendering capability by adding a new helm_template tool to the MCP server.

Related Issue(s)

Fixes #25

Type of Change

  • Feature (new functionality)
  • Bug fix (fixes an issue)
  • Documentation update
  • Code refactor
  • Performance improvement
  • Tests
  • Infrastructure/build changes
  • Other (please describe):

Testing

Please describe the tests you've added/performed to verify your changes.

Checklist

  • My code follows the coding standards for this project
  • I have added/updated necessary documentation
  • I have added tests that prove my fix/feature works
  • New and existing tests pass with my changes
  • I have checked for and resolved any merge conflicts
  • My commits follow the Conventional Commits format
  • I have linked this PR to relevant issue(s)

Screenshots (if applicable)

Additional Notes

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 4, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added ability to render Helm charts as templates without installing releases.
    • Supports release name, chart selection, optional namespace, YAML values, and inclusion of CRDs.
    • Operates in read-only contexts and returns the rendered output for review.
  • Reliability
    • Provides clear error reporting on failures and cleans up temporary files automatically.

Walkthrough

Adds a new async public tool function helm_template to mcp/tools/helm.py that runs helm template (with optional namespace, include_crds) and supports inline YAML values via a temporary file. It returns a ToolOutput, ensures temp-file cleanup, and reports structured errors on failure.

Changes

Cohort / File(s) Change summary
Helm tooling
mcp/tools/helm.py
Added async def helm_template(release_name, chart, namespace: Optional[str]=..., values: Optional[str]=..., include_crds: Optional[bool]=...) -> ToolOutput decorated with @mcp.tool(title="Render Helm Template", tags=["helm"], annotations={"readOnlyHint": True}). Builds helm template command, writes values to a temporary YAML file when provided, runs the command, cleans up temp file on success/error, and returns command output or structured error.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as Client/UI
  participant MCP as MCP Server
  participant Helm as Helm CLI
  participant FS as Temp File

  User->>UI: Request render (release, chart, ns?, values?, include_crds?)
  UI->>MCP: Call helm_template(params)
  alt values provided
    MCP->>FS: Create temp file with YAML values
    MCP->>Helm: helm template <release> <chart> [-n ns] -f <temp> [--include-crds]
    Helm-->>MCP: Rendered YAML or error
    MCP->>FS: Cleanup temp file
  else no values
    MCP->>Helm: helm template <release> <chart> [-n ns] [--include-crds]
    Helm-->>MCP: Rendered YAML or error
  end
  alt success
    MCP-->>UI: ToolOutput { content: rendered YAML }
  else error
    MCP-->>UI: ToolOutput { error: message }
  end

  rect rgba(200,235,255,0.25)
    note right of MCP: Read-only operation (annotation)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • KaranJagtiani

Poem

I thump my paw, templates bloom anew,
Charts unfurl neat rows of YAML dew,
A temp file crinkles, values tucked inside,
CRDs hop in on a gentle glide.
No installs tonight—just render and view. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The title concisely and accurately describes the primary change by indicating that the helm_template tool call is being added to the MCP server for rendering manifests, following the project’s conventional commit style and omitting unnecessary details.
Linked Issues Check ✅ Passed The changes fully satisfy issue #25 by introducing the helm_template tool with the required parameters, command behavior, temporary values file handling, readOnlyHint annotation, and helm tag as specified in the linked issue.
Out of Scope Changes Check ✅ Passed All modifications are confined to implementing the helm_template tool and directly relate to the objectives in issue #25, with no unrelated or extraneous changes detected.
Description Check ✅ Passed The pull request description clearly outlines the implementation of a read-only Helm rendering capability by adding the new helm_template tool, references the related issue #25, and details type, testing, and checklist items, making it directly relevant to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@KaranJagtiani KaranJagtiani self-requested a review October 7, 2025 06:14
Comment thread mcp/tools/helm.py Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81c8e46 and 8c52446.

📒 Files selected for processing (1)
  • mcp/tools/helm.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.13.3)
mcp/tools/helm.py

358-358: Consider moving this statement to an else block

(TRY300)


359-359: Do not catch blind exception: Exception

(BLE001)


363-363: Do not use bare except

(E722)


363-364: try-except-pass detected, consider logging the exception

(S110)


365-365: Use explicit conversion flag

Replace with conversion flag

(RUF010)

🔇 Additional comments (3)
mcp/tools/helm.py (3)

323-338: LGTM! Signature and decorator align with requirements.

The function signature correctly implements all parameters specified in issue #25, and the readOnlyHint: True annotation properly marks this as a read-only tool.


339-346: LGTM! Command construction is correct.

The command building logic properly handles optional parameters and follows the established pattern in this file.


366-367: LGTM! Clean fallback for the no-values case.

The implementation correctly handles rendering without custom values.

Comment thread mcp/tools/helm.py
Copy link
Copy Markdown
Member

@KaranJagtiani KaranJagtiani left a comment

Choose a reason for hiding this comment

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

Great! Now just squash your commits into one

…er manifests

Remove comments

feat (mcp): add the helm_template tool call to the MCP server to render manifests#
@Sachin-chaurasiya
Copy link
Copy Markdown
Contributor Author

Great! Now just squash your commits into one

Done

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
mcp/tools/helm.py (1)

348-367: Exception handling issues persist from previous review.

The exception handling has the same issues previously flagged for similar code in helm_install_with_values:

  1. Line 359: Catching bare Exception masks unexpected errors (should catch OSError for file I/O)
  2. Line 363: Bare except: silently swallows cleanup exceptions (should catch OSError)
  3. No logging means silent failures hinder debugging
  4. Line 358: Return should be in else block (TRY300)
  5. Line 365: Use f-string conversion flag (!s) instead of str()

Apply this diff to fix the exception handling:

     if values:
         try:
             with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as f:
                 f.write(values)
                 values_file = f.name
 
             cmd += f" -f {values_file}"
             result = await run_helm_command(cmd)
 
             os.unlink(values_file)
-            return result
-        except Exception as e:
+        except OSError as e:
+            # Handle file I/O errors specifically
             if "values_file" in locals():
                 try:
                     os.unlink(values_file)
-                except:
+                except OSError:
+                    # Log but don't fail if cleanup fails
                     pass
-            return {"output": f"Error rendering Helm template: {str(e)}", "error": True}
-    else:
-        return await run_helm_command(cmd)
+            return {"output": f"Error rendering Helm template: {e!s}", "error": True}
+        else:
+            return result
+    return await run_helm_command(cmd)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c52446 and 7ff76d9.

📒 Files selected for processing (1)
  • mcp/tools/helm.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.13.3)
mcp/tools/helm.py

358-358: Consider moving this statement to an else block

(TRY300)


359-359: Do not catch blind exception: Exception

(BLE001)


363-363: Do not use bare except

(E722)


363-364: try-except-pass detected, consider logging the exception

(S110)


365-365: Use explicit conversion flag

Replace with conversion flag

(RUF010)

🔇 Additional comments (2)
mcp/tools/helm.py (2)

323-339: LGTM! Function signature and metadata match requirements.

The function signature correctly implements all required parameters from issue #25, and the tool is properly annotated as read-only with {"readOnlyHint": True}.


340-346: Command building logic is correct.

The command construction properly handles optional namespace and include_crds flags according to Helm CLI conventions.

Comment thread mcp/tools/helm.py
Copy link
Copy Markdown
Member

@KaranJagtiani KaranJagtiani left a comment

Choose a reason for hiding this comment

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

LGTM!

@KaranJagtiani KaranJagtiani merged commit 3e0921f into skyflo-ai:main Oct 8, 2025
1 check passed
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.

Add the helm_template tool call to the MCP server to render manifests

2 participants