Skip to content

Commit 6e23a6a

Browse files
committed
feat: add MCP integration and tool listing
1 parent f7a1356 commit 6e23a6a

File tree

5 files changed

+9
-56
lines changed

5 files changed

+9
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ docs/_build
7272

7373
# Mypy Cache
7474
.mypy_cache/
75+
.aider*

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def read(*names, **kwargs):
6868
"tabulate~=0.9.0",
6969
"requests>=2.31",
7070
"sqlglot~=25.30.0",
71+
"mcp~=1.9.0"
7172
],
7273
extras_require={
7374
# eg:

src/datapilot/cli/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import click
22

3+
from datapilot.core.mcp_utils.mcp import mcp
34
from datapilot.core.platforms.dbt.cli.cli import dbt
45

56

@@ -9,3 +10,4 @@ def datapilot():
910

1011

1112
datapilot.add_command(dbt)
13+
datapilot.add_command(mcp)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DBT = []
2+
SQL = []

src/datapilot/core/mcp_utils/mcp.py

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -21,62 +21,9 @@ def create_mcp_proxy():
2121
content = click.edit()
2222
if content is None:
2323
click.echo("No input provided.")
24-
return
25-
26-
try:
27-
config_data = json.loads(content)
28-
mcp_config = config_data.get("mcp", {})
29-
30-
# Process inputs
31-
inputs = []
32-
for input_def in mcp_config.get("inputs", []):
33-
inputs.append(InputParameter(
34-
name=input_def.get("name", input_def["id"]),
35-
type=input_def["type"],
36-
required=input_def.get("required", False),
37-
key=input_def["id"].lower(),
38-
description=input_def["description"],
39-
encrypted=input_def.get("password", False)
40-
))
41-
42-
# Process servers
43-
tool_config = []
44-
for server_name, server_def in mcp_config.get("servers", {}).items():
45-
# Command config
46-
tool_config.append(IntegrationConfigItem(
47-
key="command",
48-
value=server_def["command"]
49-
))
50-
51-
# Arguments config
52-
tool_config.append(IntegrationConfigItem(
53-
key="arguments",
54-
value=server_def.get("args", [])
55-
))
56-
57-
# Environment variables
58-
env_items = []
59-
for var_name, var_value in server_def.get("env", {}).items():
60-
if var_value.startswith("${input:"):
61-
_, input_id = var_value[2:-1].split(":")
62-
var_value = f"${{{input_id}}}"
63-
64-
env_items.append({"key": var_name, "value": var_value})
65-
66-
tool_config.append(IntegrationConfigItem(
67-
key="env",
68-
value=env_items
69-
))
70-
71-
integration_model = CustomDatamateIntegrationModel(
72-
config=inputs,
73-
toolConfig=tool_config
74-
)
75-
76-
click.echo(json.dumps(integration_model, cls=EnhancedJSONEncoder, indent=2))
77-
78-
except Exception as e:
79-
click.echo(f"Error processing config: {str(e)}")
24+
25+
output = asyncio.run(list_tools())
26+
click.echo(json.dumps(output, indent=2))
8027

8128
async def list_tools(command: str, args: list[str], env: dict[str, str]) -> str:
8229
command = shutil.which(command)

0 commit comments

Comments
 (0)