Commit 7db3b24
authored
Add support for Python debugger (#391)
## Summary
Adds Python debugger support by implementing `streamable-http` transport
alongside the default `stdio` transport.
- Maintains the behavior of being able to use `task inspector` command
to test tools via the MCP Inspector without debugging
- Adds support to run the VS Code debugger with MCP Inspector
- Adds support to attach a debugger in general to MCP Inspector
## What Changed
- Added `MCP_TRANSPORT` environment variable support to switch between
`stdio` (default for prod) and `streamable-http` (default for local dev
using `task` or VS Code debugger) transports
- Updated `task dev` and `task inspector` to work directly with the
Python interpreter by default for debugger compatibility (`mcp run`
defaults to `stdio` transport)
- Added `validate_transport` in `src/dbt_mcp/config/transport.py` to
properly handle transport types
Note:
- `CONTRIBUTING.md` documents the three different options/workflows
enabled for local dev!
- This is a development-only change. Production usage remains unchanged
(the server defaults to `stdio` transport when `MCP_TRANSPORT` is not
set)
## Why
The `stdio` transport doesn't support Python debuggers because
stdin/stdout are all used up for MCP communication. With
`streamable-http` transport as an option, devs can now use full debugger
capabilities while testing with MCP Inspector.
## Related Issues
Closes #361
## Checklist
- [x] I have performed a self-review of my code
- [ ] I have made corresponding changes to the documentation (in
https://github.com/dbt-labs/docs.getdbt.com) if required
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
## Additional Notes
### Scenarios / Workflows Tested:
#### 1. Option 1: `task inspector` to simply use MCP Inspector (with
`stdio` transport) to run tools without debugging
MCP Inspector using STDIO transport:
<img width="1917" height="1263" alt="Screenshot 2025-10-07 at 3 40
08 PM"
src="https://github.com/user-attachments/assets/a2eea430-d35d-4171-951f-7b7e10ea1ab6"
/>
#### 2. Option 2: VS Code Debugger + MCP Inspector (`streamable-http`
transport)
MCP Inspector using Streamable HTTP transport:
<img width="1920" height="1280" alt="Screenshot 2025-10-07 at 3 37
32 PM"
src="https://github.com/user-attachments/assets/d90ad85b-b3a2-4e26-95a8-a3dfc9bfb7dd"
/>
VS Code debugger with breakpoint set (triggered by call in MCP Inspector
above ^^):
<img width="1683" height="1248" alt="Screenshot 2025-10-07 at 3 38
59 PM"
src="https://github.com/user-attachments/assets/b06d112e-d4ef-4c04-b195-1eb241759718"
/>
#### 3. Claude Desktop to ensure production server initialize still
works properly with `stdio` transport
Claude Desktop successfully uses my dev dbt MCP instance via STDIO
transport:
<img width="1224" height="861" alt="Screenshot 2025-10-07 at 8 53 03 AM"
src="https://github.com/user-attachments/assets/e8da6405-7f52-417a-9b2d-850da7ae69a4"
/>
Admittedly, I haven't yet tested "Option 3" from the `CONTRIBUTING.md`
file which involves manually attaching a debugger to the server that's
run with `task dev`. It's the same exact underlying principals as using
the VS Code debugger (which I have verified), but with more manual
configuration and use. I will try and put some time into that here soon.1 parent 8af89bd commit 7db3b24
7 files changed
Lines changed: 87 additions & 6 deletions
File tree
- .changes/unreleased
- .vscode
- src/dbt_mcp
- config
- tests/unit/config
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
4 | 8 | | |
5 | 9 | | |
6 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
80 | 105 | | |
81 | 106 | | |
82 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | | - | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | | - | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | | - | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments