Skip to content

Commit c0f8779

Browse files
authored
Merge branch 'main' into redirect_readme
2 parents be66d78 + c361bd2 commit c0f8779

14 files changed

Lines changed: 1266 additions & 7 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Under the Hood
2+
body: LangGraph create_react_agent example
3+
time: 2025-08-11T16:33:02.306539-05:00

.changes/v0.4.2.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## v0.4.2 - 2025-08-13
2+
### Enhancement or New Feature
3+
* Add default --limit to show tool
4+
### Under the Hood
5+
* Define toolsets
6+
### Bug Fix
7+
* Fix the prompt to ensure grain is passed even for non-time group by"

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
77
and is generated by [Changie](https://github.com/miniscruff/changie).
88

99

10+
## v0.4.2 - 2025-08-13
11+
### Enhancement or New Feature
12+
* Add default --limit to show tool
13+
### Under the Hood
14+
* Define toolsets
15+
### Bug Fix
16+
* Fix the prompt to ensure grain is passed even for non-time group by"
17+
1018
## v0.4.1 - 2025-08-08
1119
### Under the Hood
1220
* Upgrade dbt-sl-sdk
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

examples/langgraph_agent/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# LangGraph Agent Example
2+
3+
This is a simple example of how to create conversational agent with remote dbt MCP & LangGraph.
4+
5+
## Usage
6+
7+
1. Set an `ANTHROPIC_API_KEY` environment variable with your Anthropic API key.
8+
2. Run `uv run main.py`.

examples/langgraph_agent/__init__.py

Whitespace-only changes.

examples/langgraph_agent/main.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# mypy: ignore-errors
2+
3+
import asyncio
4+
import os
5+
6+
from langchain_mcp_adapters.client import MultiServerMCPClient
7+
from langgraph.checkpoint.memory import InMemorySaver
8+
from langgraph.prebuilt import create_react_agent
9+
10+
11+
def print_stream_item(item):
12+
if "agent" in item:
13+
content = [
14+
part
15+
for message in item["agent"]["messages"]
16+
for part in (
17+
message.content
18+
if isinstance(message.content, list)
19+
else [message.content]
20+
)
21+
]
22+
for c in content:
23+
if isinstance(c, str):
24+
print(f"Agent > {c}")
25+
elif "text" in c:
26+
print(f"Agent > {c['text']}")
27+
elif c["type"] == "tool_use":
28+
print(f" using tool: {c['name']}")
29+
30+
31+
async def main():
32+
url = f"https://{os.environ.get('DBT_HOST')}/api/ai/v1/mcp/"
33+
headers = {
34+
"x-dbt-user-id": os.environ.get("DBT_USER_ID"),
35+
"x-dbt-prod-environment-id": os.environ.get("DBT_PROD_ENV_ID"),
36+
"x-dbt-dev-environment-id": os.environ.get("DBT_DEV_ENV_ID"),
37+
"Authorization": f"token {os.environ.get('DBT_TOKEN')}",
38+
}
39+
client = MultiServerMCPClient(
40+
{
41+
"dbt": {
42+
"url": url,
43+
"headers": headers,
44+
"transport": "streamable_http",
45+
}
46+
}
47+
)
48+
tools = await client.get_tools()
49+
agent = create_react_agent(
50+
model="anthropic:claude-3-7-sonnet-latest",
51+
tools=tools,
52+
# This allows the agent to have conversational memory.
53+
checkpointer=InMemorySaver(),
54+
)
55+
# This config maintains the conversation thread.
56+
config = {"configurable": {"thread_id": "1"}}
57+
while True:
58+
user_input = input("User > ")
59+
async for item in agent.astream(
60+
{"messages": {"role": "user", "content": user_input}},
61+
config,
62+
):
63+
print_stream_item(item)
64+
65+
66+
if __name__ == "__main__":
67+
asyncio.run(main())
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[project]
2+
name = "langgraph-agent"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = [
8+
"langchain-mcp-adapters>=0.1.9",
9+
"langchain[anthropic]>=0.3.27",
10+
"langgraph>=0.6.4",
11+
]

examples/langgraph_agent/uv.lock

Lines changed: 1085 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dbt_mcp/dbt_cli/tools.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ def test(
117117

118118
def show(
119119
sql_query: str = Field(description=get_prompt("dbt_cli/args/sql_query")),
120-
limit: int | None = Field(
121-
default=None, description=get_prompt("dbt_cli/args/limit")
122-
),
120+
limit: int = Field(default=5, description=get_prompt("dbt_cli/args/limit")),
123121
) -> str:
124122
args = ["show", "--inline", sql_query, "--favor-state"]
125123
# This is quite crude, but it should be okay for now

0 commit comments

Comments
 (0)