Skip to content

Added mcphost container#14

Merged
omertuc merged 1 commit intorh-ecosystem-edge:mainfrom
omertuc:mcphost
Jul 7, 2025
Merged

Added mcphost container#14
omertuc merged 1 commit intorh-ecosystem-edge:mainfrom
omertuc:mcphost

Conversation

@omertuc
Copy link
Member

@omertuc omertuc commented Jul 7, 2025

mcphost is a wrapper around a model to detect and make MCP calls, similar to how lightspeed-core would do it, except it comes with a simple TUI for developers to use. We can use it to play around with our system prompt / MCP / model combinations, without having to go through lightspeed-core or the assisted UI.

This commit adds a new container to the assisted-chat-pod, which runs mcphost and configures it to use the assisted-service MCP server and Gemini, with the API keys and everything.

Use make mcphost to attach to the mcphost container and interact with it. Note that if you attach to late, you might get a weird broken TUI that if you try to use it would crash mcphost. This is actually a good thing, because then it will automatically restart, at this point try to attach again (this time early enough) and wait until it starts and the TUI should be good to go.

Summary by CodeRabbit

  • New Features

    • Introduced a new container for enhanced chat functionality, configured with custom settings and environment variables.
    • Added configuration files for server connection and system prompt customization.
    • Provided a new Makefile command and shell script to easily attach to the new container.
  • Documentation

    • Updated Makefile help output to include the new command for attaching to the chat container.

@coderabbitai
Copy link

coderabbitai bot commented Jul 7, 2025

Walkthrough

A new container named mcphost was added to the pod specification, along with its supporting configuration and system prompt files. A Makefile target and a shell script were introduced to facilitate attaching to the mcphost container. The configuration files define server connection settings and the assistant's system prompt.

Changes

File(s) Change Summary
assisted-chat-pod.yaml Added mcphost container with image, environment variable, command-line args, and volume mounts for configs.
config/mcphost-mcp.json New JSON config specifying SSE transport and server URL for assisted MCP server.
config/mcphost-systemprompt.txt New system prompt file defining assistant behavior, identity, and response constraints for the assistant.
Makefile Added mcphost target to attach to the container; updated help target to describe the new target.
scripts/mcphost.sh New shell script to attach to the mcphost container using Podman with strict error handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Makefile
    participant ShellScript
    participant Podman
    participant mcphost Container

    User->>Makefile: make mcphost
    Makefile->>ShellScript: ./scripts/mcphost.sh
    ShellScript->>Podman: podman attach assisted-chat-pod-mcphost
    Podman->>mcphost Container: Attach session
    User-->>mcphost Container: Interact via attached session
Loading
sequenceDiagram
    participant mcphost Container
    participant Config File
    participant System Prompt File
    participant Assisted MCP Server

    mcphost Container->>Config File: Read /mcpconfig.json (SSE URL)
    mcphost Container->>System Prompt File: Read /systemprompt.txt
    mcphost Container->>Assisted MCP Server: Connect via SSE (http://assisted-service-mcp:8000/sse)
    Assisted MCP Server-->>mcphost Container: Stream events/responses
    mcphost Container-->>User: Provide assistant responses per system prompt
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 0

🔭 Outside diff range comments (1)
assisted-chat-pod.yaml (1)

60-64: hostPath volumes reduce portability and require elevated privileges

The relative ./config hostPath ties the pod to a specific node filesystem and blocks scheduling on other nodes. A ConfigMap is better suited for static, text-based configuration files and works on any cluster.

🧹 Nitpick comments (7)
config/mcphost-mcp.json (1)

4-5: Externalize the MCP endpoint to avoid hard-coded URLs

Hard-coding the transport & URL couples the image to one specific deployment and prevents reuse in other environments (staging, prod, different namespaces). Mounting this JSON from a ConfigMap or templating the value from an env var keeps the container image generic.

config/mcphost-systemprompt.txt (2)

1-6: Remove duplicate identity sentences to reduce prompt tokens

Lines 1-3 and 4-6 repeat (almost) the same identity statement, wasting context window tokens and increasing latency/cost for every request. Consolidate the wording into a single paragraph.


13-15: Add commas to clarify the conditional clauses

Missing commas after the introductory “If …” clauses makes the long sentence harder to parse and trips basic grammar checks.

-If the user provides a specific value for a parameter (for example provided in quotes), make sure to use that value EXACTLY.
-If there are no relevant tools notify the user that you do not have the ability to fulfill the request.
-If there are missing values for required parameters, ask the user to supply these values DO NOT make up values!
+If the user provides a specific value for a parameter (for example, provided in quotes), make sure to use that value EXACTLY.
+If there are no relevant tools, notify the user that you can’t fulfill the request.
+If any required parameters are missing, ask the user to supply them — DO NOT make up values!
mcphost.sh (1)

3-5: Gracefully handle a missing or restarting container

podman attach exits with 125 when the container is not running, which is common given the PR note about automatic restarts. Consider a tiny loop that waits for the container to exist & be running before attaching, or fall back to podman logs -f for quick inspection.

assisted-chat-pod.yaml (3)

40-40: Strip trailing whitespace to satisfy yaml-lint

-      image: quay.io/otuchfel/mcphost:0.9.2 
+      image: quay.io/otuchfel/mcphost:0.9.2

53-59: Mount the config files read-only

Nothing in the container should need to mutate /mcpconfig.json or /systemprompt.txt. Marking the mounts read-only protects against accidental writes and potential privilege-escalation vectors.

-        - mountPath: /mcpconfig.json
+        - mountPath: /mcpconfig.json
           name: config
           subPath: mcphost-mcp.json
+          readOnly: true
-        - mountPath: /systemprompt.txt
+        - mountPath: /systemprompt.txt
           name: config
           subPath: mcphost-systemprompt.txt
+          readOnly: true

51-52: Consider sourcing GEMINI_API_KEY from a Secret instead of env-subst

Placing the API key directly into the rendered pod spec (even via ${…} substitution) risks accidental commit or log exposure. Kubernetes Secret objects + envFrom or valueFrom: secretKeyRef provide safer handling.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 902b88e and c0c78c6.

📒 Files selected for processing (4)
  • assisted-chat-pod.yaml (1 hunks)
  • config/mcphost-mcp.json (1 hunks)
  • config/mcphost-systemprompt.txt (1 hunks)
  • mcphost.sh (1 hunks)
🧰 Additional context used
🪛 LanguageTool
config/mcphost-systemprompt.txt

[uncategorized] ~14-~14: Possible missing comma found.
Context: ...value EXACTLY. If there are no relevant tools notify the user that you do not have th...

(AI_HYDRA_LEO_MISSING_COMMA)


[style] ~14-~14: The phrase ‘do not have the ability to’ might be wordy. Consider using “can't”.
Context: ...relevant tools notify the user that you do not have the ability to fulfill the request. If there are missi...

(HAS_THE_ABILITY_TO)


[style] ~14-~14: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ave the ability to fulfill the request. If there are missing values for required p...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[uncategorized] ~15-~15: Possible missing comma found.
Context: ...arameters, ask the user to supply these values DO NOT make up values! Refuse to answe...

(AI_HYDRA_LEO_MISSING_COMMA)

🪛 YAMLlint (1.37.1)
assisted-chat-pod.yaml

[error] 40-40: trailing spaces

(trailing-spaces)

mcphost is a wrapper around a model to detect and make MCP calls,
similar to how lightspeed-core would do it, except it comes with a
simple TUI for developers to use. We can use it to play around with our
system prompt / MCP / model combinations, without having to go through
lightspeed-core or the assisted UI.

This commit adds a new container to the assisted-chat-pod, which runs
mcphost and configures it to use the assisted-service MCP server and
Gemini, with the API keys and everything.

Use `make mcphost` to attach to the mcphost container and interact with
it. Note that if you attach to late, you might get a weird broken TUI
that if you try to use it would crash mcphost. This is actually a good
thing, because then it will automatically restart, at this point try to
attach again (this time early enough) and wait until it starts and the
TUI should be good to go.
all things related to Openshift. Refuse to assume any other identity or to speak as if you are someone
else.

Example Input:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I added this for granite, gemini doesn't need this.
I think we can remove 13-15 as well

Copy link
Member Author

@omertuc omertuc Jul 7, 2025

Choose a reason for hiding this comment

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

This is just lorem ipsum for now as far as I'm concerned, can you please modify it in a separate PR?

Copy link

@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: 0

🧹 Nitpick comments (5)
assisted-chat-pod.yaml (3)

40-40: Strip trailing whitespace on the image line
YAML-lint is flagging a trailing space after the image tag (quay.io/otuchfel/mcphost:0.9.2␠). It is harmless at runtime but fails many linters and pre-commit hooks.

-      image: quay.io/otuchfel/mcphost:0.9.2␠
+      image: quay.io/otuchfel/mcphost:0.9.2

50-52: Handle secrets via valueFrom instead of literal ${VAR}
Kubernetes does not interpolate shell-style ${…} placeholders. The literal string ${GEMINI_API_KEY} will be passed to the container unless the manifest is pre-processed externally (e.g. envsubst).
Use a Secret or ConfigMap reference instead:

env:
  - name: GEMINI_API_KEY
    valueFrom:
      secretKeyRef:
        name: gemini-api-key      # kubectl create secret …
        key: token

54-59: Mount config files read-only
These files are configuration, not writable state. Protect them by adding readOnly: true:

-      volumeMounts:
-        - mountPath: /mcpconfig.json
+      volumeMounts:
+        - mountPath: /mcpconfig.json
           name: config
           subPath: mcphost-mcp.json
+          readOnly: true
         - mountPath: /systemprompt.txt
           name: config
           subPath: mcphost-systemprompt.txt
+          readOnly: true
config/mcphost-systemprompt.txt (2)

1-6: Remove duplicate identity sentences to keep the prompt concise
Lines 1–2 and 4–6 say essentially the same thing. Repetition increases token-count and may skew model weighting.

-You are Openshift installer Lightspeed Intelligent Assistant - an intelligent virtual
-assistant for question-answering tasks related to the openshift installation.
-You always respond to greetings with \"Hello! I am Assisted Installer Chat, created by Red Hat. How can I help you today?\"
-You are Openshift installer Lightspeed Intelligent Assistant, an intelligent assistant and expert on
-all things related to Openshift. Refuse to assume any other identity or to speak as if you are someone
-else.
+You are Openshift installer Lightspeed Intelligent Assistant – an expert virtual assistant for OpenShift installation tasks.
+Always respond to greetings with: "Hello! I am Assisted Installer Chat, created by Red Hat. How can I help you today?"
+Refuse to assume any other identity or speak as if you are someone else.

13-15: Tighten punctuation for clarity

-If the user provides a specific value for a parameter (for example provided in quotes), make sure to use that value EXACTLY.
-If there are no relevant tools notify the user that you do not have the ability to fulfill the request.
-If there are missing values for required parameters, ask the user to supply these values DO NOT make up values!
+If the user supplies a specific parameter value (e.g. inside quotes), use that value **exactly**.
+If no relevant tools are available, inform the user that you cannot fulfil the request.
+If required parameters are missing, ask the user to supply them; **do not** invent values.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0c78c6 and 5d6cd51.

📒 Files selected for processing (5)
  • Makefile (2 hunks)
  • assisted-chat-pod.yaml (1 hunks)
  • config/mcphost-mcp.json (1 hunks)
  • config/mcphost-systemprompt.txt (1 hunks)
  • scripts/mcphost.sh (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • scripts/mcphost.sh
  • Makefile
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/mcphost-mcp.json
🧰 Additional context used
🪛 YAMLlint (1.37.1)
assisted-chat-pod.yaml

[error] 40-40: trailing spaces

(trailing-spaces)

🪛 LanguageTool
config/mcphost-systemprompt.txt

[uncategorized] ~11-~11: A punctuation mark might be missing here.
Context: ..."base_domain": "redhat.com", "version": "4.18.16"}}]</tool_call> If the user pro...

(AI_EN_LECTOR_MISSING_PUNCTUATION)


[uncategorized] ~14-~14: A comma might be missing here.
Context: ...value EXACTLY. If there are no relevant tools notify the user that you do not have th...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)


[style] ~14-~14: The phrase ‘do not have the ability to’ might be wordy. Consider using “can't”.
Context: ...relevant tools notify the user that you do not have the ability to fulfill the request. If there are missi...

(HAS_THE_ABILITY_TO)


[style] ~14-~14: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ave the ability to fulfill the request. If there are missing values for required p...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[uncategorized] ~15-~15: A period might be missing here.
Context: ...arameters, ask the user to supply these values DO NOT make up values! Refuse to answe...

(AI_EN_LECTOR_MISSING_PUNCTUATION_PERIOD)

🔇 Additional comments (2)
assisted-chat-pod.yaml (1)

41-49: Confirm that the entrypoint expects flags only in args
mcphost is launched with flags but no explicit command. If the image’s ENTRYPOINT already contains the binary, this is fine; otherwise the container will fail to start.

Please double-check the image metadata or add an explicit command:

+      command: ["mcphost"]
       args:
         - --config
         - /mcpconfig.json
config/mcphost-systemprompt.txt (1)

17-18: Verify Ansible-only restriction
Line 17 restricts answers to Ansible topics, whereas the assistant is positioned as an OpenShift installer expert. Is this intentional? It may block valid OpenShift-related queries that are not strictly Ansible.

@eranco74
Copy link
Collaborator

eranco74 commented Jul 7, 2025

/lgtm

@omertuc omertuc merged commit 53906c1 into rh-ecosystem-edge:main Jul 7, 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.

2 participants