Skip to content

Conversation

@Vasilije1990
Copy link
Contributor

Description

DCO Affirmation

I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin.

@pull-checklist
Copy link

pull-checklist bot commented Jul 1, 2025

Please make sure all the checkboxes are checked:

  • I have tested these changes locally.
  • I have reviewed the code changes.
  • I have added end-to-end and unit tests (if applicable).
  • I have updated the documentation and README.md file (if necessary).
  • I have removed unnecessary code and debug statements.
  • PR title is clear and follows the convention.
  • I have tagged reviewers or team members for feedback.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 1, 2025

Walkthrough

The entrypoint script now sets a default transport mode (stdio) if not specified, logs the selected mode at startup, and ensures the server is always started with a --transport argument reflecting the chosen mode. The logic for launching the server, including debug mode, is updated to consistently pass the transport mode.

Changes

File(s) Change Summary
cognee-mcp/entrypoint.sh Sets default TRANSPORT_MODE, logs mode at startup, and always passes --transport to server start

Poem

In the warren, scripts now know
Which way the data streams shall flow—
"stdio" or "sse,"
The mode is set, as clear can be.
With each new hop, the logs will show
How rabbits make their servers go! 🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch enable_mcp_switch_sse

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • 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 auto-generate unit tests to generate unit tests for 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
Contributor

@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

🧹 Nitpick comments (2)
cognee-mcp/entrypoint.sh (2)

35-35: Minor: quote the variable in log messages
Although unlikely, quoting prevents word-splitting if the value ever contains spaces.

-echo "Starting Cognee MCP Server with transport mode: $TRANSPORT_MODE"
+echo "Starting Cognee MCP Server with transport mode: \"$TRANSPORT_MODE\""

40-61: Collapse the nested transport/debug logic to eliminate duplication
Four near-identical branches make the script harder to maintain and easy to drift. Build the common argument array once and delegate to either debugpy or cognee.

-# Modified startup with transport mode selection and error handling
-if [ "$ENVIRONMENT" = "dev" ] || [ "$ENVIRONMENT" = "local" ]; then
-    if [ "$DEBUG" = "true" ]; then
-        echo "Waiting for the debugger to attach..."
-        if [ "$TRANSPORT_MODE" = "sse" ]; then
-            exec python -m debugpy --wait-for-client --listen 0.0.0.0:5678 -m cognee --transport sse
-        else
-            exec python -m debugpy --wait-for-client --listen 0.0.0.0:5678 -m cognee --transport stdio
-        fi
-    else
-        if [ "$TRANSPORT_MODE" = "sse" ]; then
-            exec cognee --transport sse
-        else
-            exec cognee --transport stdio
-        fi
-    fi
-else
-    if [ "$TRANSPORT_MODE" = "sse" ]; then
-        exec cognee --transport sse
-    else
-        exec cognee --transport stdio
-    fi
-fi
+# Build common args once
+CMD_ARGS=(--transport "$TRANSPORT_MODE")
+
+# Choose launcher
+if [[ "$ENVIRONMENT" == "dev" || "$ENVIRONMENT" == "local" ]] && [[ "$DEBUG" == "true" ]]; then
+  echo "Waiting for the debugger to attach..."
+  exec python -m debugpy --wait-for-client --listen 0.0.0.0:5678 -m cognee "${CMD_ARGS[@]}"
+else
+  exec cognee "${CMD_ARGS[@]}"
+fi
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cb905bb and d14e514.

📒 Files selected for processing (1)
  • cognee-mcp/entrypoint.sh (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: End-to-End Tests / Test using different async databases in parallel in Cognee
  • GitHub Check: End-to-End Tests / Server Start Test
  • GitHub Check: End-to-End Tests / Deletion Test
  • GitHub Check: End-to-End Tests / S3 Bucket Test
  • GitHub Check: End-to-End Tests / Run Telemetry Pipeline Test
  • GitHub Check: End-to-End Tests / Deduplication Test
  • GitHub Check: Basic Tests / Run Basic Graph Tests
  • GitHub Check: End-to-End Tests / Run Telemetry Test
  • GitHub Check: Basic Tests / Run Simple Examples
  • GitHub Check: Basic Tests / Run Integration Tests
  • GitHub Check: Basic Tests / Run Unit Tests
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (python)

Comment on lines +7 to +10
# Set default transport mode if not specified
TRANSPORT_MODE=${TRANSPORT_MODE:-"stdio"}
echo "Transport mode: $TRANSPORT_MODE"

Copy link
Contributor

@coderabbitai coderabbitai bot Jul 1, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add upfront validation for unsupported transport modes
Right now any value other than sse silently falls back to stdio. Explicitly rejecting unknown values avoids hard-to-trace misconfigurations.

 TRANSPORT_MODE=${TRANSPORT_MODE:-"stdio"}
+case "$TRANSPORT_MODE" in
+  stdio|sse) ;;            # accepted values
+  *)
+    echo "Unsupported TRANSPORT_MODE='$TRANSPORT_MODE'. Allowed: stdio | sse."
+    exit 1
+esac
 echo "Transport mode: $TRANSPORT_MODE"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Set default transport mode if not specified
TRANSPORT_MODE=${TRANSPORT_MODE:-"stdio"}
echo "Transport mode: $TRANSPORT_MODE"
# Set default transport mode if not specified
TRANSPORT_MODE=${TRANSPORT_MODE:-"stdio"}
case "$TRANSPORT_MODE" in
stdio|sse) ;; # accepted values
*)
echo "Unsupported TRANSPORT_MODE='$TRANSPORT_MODE'. Allowed: stdio | sse."
exit 1
esac
echo "Transport mode: $TRANSPORT_MODE"
🤖 Prompt for AI Agents
In cognee-mcp/entrypoint.sh around lines 7 to 10, the script sets TRANSPORT_MODE
with a default of "stdio" but does not validate if the provided value is
supported. Add a validation step after setting TRANSPORT_MODE to explicitly
check if its value is either "stdio" or "sse". If it is not one of these, print
an error message and exit the script with a non-zero status to prevent silent
fallback and misconfiguration.

Copy link

@mingfang mingfang Jul 1, 2025

Choose a reason for hiding this comment

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

Think the upfront validation is beneficial and can simplify the code below to simply
--transport $TRANSPORT_MODE, avoiding the if checks, since we already know the value is valid.

Copy link
Contributor

Choose a reason for hiding this comment

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

No description provided.

@Vasilije1990 Vasilije1990 merged commit 9116882 into main Jul 1, 2025
20 of 21 checks passed
@Vasilije1990 Vasilije1990 deleted the enable_mcp_switch_sse branch July 1, 2025 11:15
@coderabbitai coderabbitai bot mentioned this pull request Aug 4, 2025
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.

4 participants