-
Notifications
You must be signed in to change notification settings - Fork 9
LangChain: Add example using MCP #1033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning Rate limit exceeded@amotl has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 59 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (4)
WalkthroughA new agent integration script demonstrates using LangChain/LangGraph with a CrateDB MCP server, including setup instructions. The requirements file adds dependencies for LangChain MCP adapters and LangGraph. The workflow adds a CrateDB MCP service and matrix for versioning. Database initialization is scripted with a new SQL file and test fixture. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant AgentScript
participant MCPClient
participant LangGraphAgent
participant OpenAIModel
User->>AgentScript: Run main()
AgentScript->>MCPClient: Connect to MCP server
MCPClient-->>AgentScript: Return available tools
AgentScript->>LangGraphAgent: Instantiate with tools and GPT-4.1
AgentScript->>LangGraphAgent: Query: "What is the average value of sensor 1?"
LangGraphAgent->>OpenAIModel: Process query
OpenAIModel-->>LangGraphAgent: Return response
LangGraphAgent-->>AgentScript: Return final response
AgentScript->>User: Print query and response
Estimated code review effort3 (~40 minutes) — Moderate complexity with new async agent logic, workflow and service setup, database initialization scripts, and test fixture additions. Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🔭 Outside diff range comments (1)
.github/workflows/ml-langchain.yml (1)
5-5:branches: ~is not a valid filter – drops parsing in Actions.YAML
~means null, but thepull_request.brancheskey expects either an array of branch globs or omission.
Keeping it asnullcauses the workflow definition to be rejected by GitHub.- branches: ~ +# ─ Option A: watch every branch – simply delete the key +# ─ Option B: explicit wildcard + # branches: + # - '*'
🧹 Nitpick comments (1)
.github/workflows/ml-langchain.yml (1)
41-46: Matrix blow-up & readabilityAdding
cratedb-mcp-versioncreates a full Cartesian product with every Python + CrateDB version.
Right now each dimension has only one value, but if more are appended later the job count will explode.Recommend:
strategy: matrix: include: - os: ubuntu-latest python-version: '3.11' cratedb-version: nightly cratedb-mcp-version: pr-50Keeps the job count explicit and avoids surprises.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
.github/workflows/ml-langchain.yml(2 hunks)topic/machine-learning/llm-langchain/.gitignore(1 hunks)topic/machine-learning/llm-langchain/agent_with_mcp.py(1 hunks)topic/machine-learning/llm-langchain/init.sql(1 hunks)topic/machine-learning/llm-langchain/requirements.txt(1 hunks)topic/machine-learning/llm-langchain/test.py(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- topic/machine-learning/llm-langchain/.gitignore
- topic/machine-learning/llm-langchain/init.sql
🚧 Files skipped from review as they are similar to previous changes (3)
- topic/machine-learning/llm-langchain/requirements.txt
- topic/machine-learning/llm-langchain/test.py
- topic/machine-learning/llm-langchain/agent_with_mcp.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: amotl
PR: crate/cratedb-examples#1032
File: topic/machine-learning/llama-index/demo_nlsql.py:28-29
Timestamp: 2025-07-20T00:14:38.691Z
Learning: In demonstration and example code within the cratedb-examples repository, prefer simpler code without extensive error handling to maintain clarity and readability of the examples.
.github/workflows/ml-langchain.yml (1)
Learnt from: amotl
PR: crate/cratedb-examples#937
File: topic/machine-learning/llm-langchain/requirements-dev.txt:2-2
Timestamp: 2025-05-12T20:10:38.614Z
Learning: The cratedb-toolkit package supports various extras including "io", "datasets", "influxdb", "mongodb", "testing", and many others.
There was a problem hiding this 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 (4)
topic/machine-learning/llm-langchain/README.md (4)
10-15: Clarify relationship between LangChain and LangGraphThe paragraph abruptly switches from LangChain to LangGraph without an explicit transition or header. Consider either:
- Adding a short sentence explaining why LangGraph is relevant in this context (e.g., “Because the new example relies on LangGraph, …”), or
- Moving the LangGraph blurb into its own subsection (e.g., “### About LangGraph”).
This will help readers who are skimming understand the distinction at a glance.
21-22: Maintain bullet-list orderingThe new “Text-to-SQL” item is great, but the list is now semi-random (chatbots, document QA, Text-to-SQL, …). For discoverability, consider grouping by domain or alphabetically.
93-98: Add a clickable link for the newagent_with_mcp.pyexampleAll other examples use markdown links or badge sets; this one is plain text. For consistency (and reader convenience), wrap the filename in a GitHub link and optionally add a quick-launch badge.
171-175: Minor phrasing nit“Regeneration of the Jupyter Notebook” → “regeneration of Jupyter notebooks” (plural, generic).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.github/workflows/ml-langchain.yml(2 hunks)topic/machine-learning/llm-langchain/.gitignore(1 hunks)topic/machine-learning/llm-langchain/README.md(4 hunks)topic/machine-learning/llm-langchain/agent_with_mcp.py(1 hunks)topic/machine-learning/llm-langchain/init.sql(1 hunks)topic/machine-learning/llm-langchain/requirements.txt(1 hunks)topic/machine-learning/llm-langchain/test.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
- topic/machine-learning/llm-langchain/.gitignore
- topic/machine-learning/llm-langchain/test.py
- topic/machine-learning/llm-langchain/requirements.txt
- topic/machine-learning/llm-langchain/init.sql
- topic/machine-learning/llm-langchain/agent_with_mcp.py
- .github/workflows/ml-langchain.yml
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: amotl
PR: crate/cratedb-examples#1032
File: topic/machine-learning/llama-index/demo_nlsql.py:28-29
Timestamp: 2025-07-20T00:14:38.691Z
Learning: In demonstration and example code within the cratedb-examples repository, prefer simpler code without extensive error handling to maintain clarity and readability of the examples.
topic/machine-learning/llm-langchain/README.md (1)
Learnt from: amotl
PR: crate/cratedb-examples#1032
File: topic/machine-learning/llama-index/demo_nlsql.py:28-29
Timestamp: 2025-07-20T00:14:38.691Z
Learning: In demonstration and example code within the cratedb-examples repository, prefer simpler code without extensive error handling to maintain clarity and readability of the examples.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Python: 3.10 CrateDB: nightly on ubuntu-latest
- GitHub Check: Python: 3.12 CrateDB: nightly on ubuntu-latest
- GitHub Check: Python: 3.11 CrateDB: nightly on ubuntu-latest
- GitHub Check: Python: 3.13 CrateDB: nightly on ubuntu-latest
🔇 Additional comments (3)
topic/machine-learning/llm-langchain/README.md (3)
101-105: Mention new dependencies in install instructionsRunning
agent_with_mcp.pyrequireslangchain-mcp-adapters,langgraph, anduvx(oruvicorn). These are not yet inrequirements.txtand the “Install” section does not call them out, which will trip up users following the README verbatim.
179-190: Double-check external linksQuick manual test:
•https://academy.langchain.com/courses/ambient-agents/– OK
•https://langchain-ai.github.io/langgraph/– redirects to 404 at the moment.If the project switched to a different docs host (
https://docs.langgraph.ai), update the link accordingly.
87-92: Broken notebook linkThe newly added Vertex-AI notebook path points to
cratedb_rag_customer_support_vertexai.ipynb, but the embedded GitHub and Colab URLs still reference the previous file (conversational_memory.ipynb). Update the two URL fragments so the badges open the intended notebook.-...(https://github.com/crate/cratedb-examples/blob/main/topic/machine-learning/llm-langchain/conversational_memory.ipynb) +...(https://github.com/crate/cratedb-examples/blob/main/topic/machine-learning/llm-langchain/cratedb_rag_customer_support_vertexai.ipynb)Likely an incorrect or invalid review comment.
| pip install -U -r requirements.txt | ||
| # Start database. | ||
| docker run --rm -it --publish=4200:4200 crate/crate:nightly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A step to execute init.sql should be added here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this. Fixed with 45f0704.
| cratedb-mcp-version: [ | ||
| 'pr-50', | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be adjusted after the next release of cratedb-mcp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved with 046d8f7.
| } | ||
| ) | ||
| tools = await client.get_tools() | ||
| agent = create_react_agent("openai:gpt-4.1", tools) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_react_agent also accepts a prompt argument. Maybe insert CrateDB's instructions here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved with 4de0d6e.
There was a problem hiding this 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 (3)
topic/machine-learning/llm-langchain/README.md (3)
10-14: Good call-out of LangGraph – maybe give it its own subsectionThe extra sentences are helpful, but the LangGraph paragraph is still tucked inside the LangChain introduction.
Consider breaking it out as its own “## About LangGraph” (or similar) to keep the two frameworks conceptually separate and skimmable.
This is purely editorial, no blocker.
101-105: Minor wording tweak for virtual-env instructions (optional)Strictly speaking,
python -m venv .venvuses the interpreter found first on PATH; some users might have multiple Python versions.
If you want to be explicit, change topython3.11 -m venv …or mention the minimum supported version (e.g. “Python ≥ 3.10”).
138-150: Heading rendered as H1 and flagged by MD026 – drop the trailing period
# Provision database.is interpreted as a level-1 heading with a trailing full-stop, triggering markdown-lint.
Convert it to a normal sentence or lower-level heading without the period:-# Provision database. +#### Provision the database
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
.github/workflows/ml-langchain.yml(2 hunks)topic/machine-learning/llm-langchain/README.md(4 hunks)topic/machine-learning/llm-langchain/agent_with_mcp.py(1 hunks)topic/machine-learning/llm-langchain/requirements.txt(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- topic/machine-learning/llm-langchain/requirements.txt
- .github/workflows/ml-langchain.yml
- topic/machine-learning/llm-langchain/agent_with_mcp.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: amotl
PR: crate/cratedb-examples#1033
File: topic/machine-learning/llm-langchain/README.md:138-156
Timestamp: 2025-07-21T18:46:07.502Z
Learning: In CrateDB MCP server configuration, the correct environment variable name is `CRATEDB_MCP_TRANSPORT`, not `CRATEDB_MCP_ADAPTER_TRANSPORT`. This variable is used throughout the CrateDB MCP codebase to specify the transport protocol.
Learnt from: amotl
PR: crate/cratedb-examples#1032
File: topic/machine-learning/llama-index/demo_nlsql.py:28-29
Timestamp: 2025-07-20T00:14:38.710Z
Learning: In demonstration and example code within the cratedb-examples repository, prefer simpler code without extensive error handling to maintain clarity and readability of the examples.
topic/machine-learning/llm-langchain/README.md (3)
Learnt from: amotl
PR: #1033
File: topic/machine-learning/llm-langchain/README.md:138-156
Timestamp: 2025-07-21T18:46:07.502Z
Learning: In CrateDB MCP server configuration, the correct environment variable name is CRATEDB_MCP_TRANSPORT, not CRATEDB_MCP_ADAPTER_TRANSPORT. This variable is used throughout the CrateDB MCP codebase to specify the transport protocol.
Learnt from: amotl
PR: #1033
File: topic/machine-learning/llm-langchain/README.md:138-156
Timestamp: 2025-07-21T18:46:07.502Z
Learning: The uvx command is the launcher program provided by the uv package manager, used to run Python tools in isolated environments without installing them globally. It is not part of uvicorn-ext.
Learnt from: amotl
PR: #1032
File: topic/machine-learning/llama-index/demo_nlsql.py:28-29
Timestamp: 2025-07-20T00:14:38.710Z
Learning: In demonstration and example code within the cratedb-examples repository, prefer simpler code without extensive error handling to maintain clarity and readability of the examples.
🪛 markdownlint-cli2 (0.17.2)
topic/machine-learning/llm-langchain/README.md
140-140: Trailing punctuation in heading
Punctuation: '.'
(MD026, no-trailing-punctuation)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Python: 3.10 CrateDB: nightly on ubuntu-latest
- GitHub Check: Python: 3.13 CrateDB: nightly on ubuntu-latest
- GitHub Check: Python: 3.11 CrateDB: nightly on ubuntu-latest
- GitHub Check: Python: 3.12 CrateDB: nightly on ubuntu-latest
🔇 Additional comments (6)
topic/machine-learning/llm-langchain/README.md (6)
21-21: 👍 Nice to see Text-to-SQL called out explicitly
No issues – this bullet rounds out the list nicely.
87-92: Vertex AI RAG example reference looks correct
Link target and framing read well.
93-98: Check file path for the newagent_with_mcp.pylinkDouble-check that the example file really lives next to the README (not in a sub-folder). A broken link here would be frustrating for users.
152-161: Instructions are clear – nothing to change
Environment variables and expected output look correct, andCRATEDB_MCP_TRANSPORTmatches the upstream codebase.
176-180: Notebook-regeneration note looks fine
No action required.
184-195: Reference section updated – links resolve correctly
All new references render and point to valid targets.
About
For Text-to-SQL purposes, exercise the langchain-mcp-adapters package together with the CrateDB MCP Server, also to validate its OCI standard image published to GHCR.
References
Backlog