Skip to content

feat: add namespace to MCP tools #1647

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/mcp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class DbtPowerUserMcpServerTools implements Disposable {

private tools: McpTool[] = [
{
namespace: "dbt",
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider extracting the constant dbt namespace into a shared constant (e.g. DBT_NAMESPACE) to reduce duplication and avoid potential typos.

name: ToolName.GET_PROJECTS,
description: `Returns detailed information about all available dbt projects including:
- projectRoot: The root directory path of the dbt project
Expand Down Expand Up @@ -205,6 +206,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.GET_COLUMNS_OF_MODEL,
description:
"Returns the column names and data types for a specified dbt model. Use this to understand a model's schema before querying it.",
Expand All @@ -227,6 +229,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.GET_COLUMNS_OF_SOURCE,
description:
"Returns the column names and data types for a specified dbt source. Use this to understand a source's schema before querying it.",
Expand Down Expand Up @@ -256,6 +259,7 @@ This must be called first to get the projectRoot parameter needed for all other
.get<boolean>("enableMcpDataSourceQueryTools", false)
? [
{
namespace: "dbt",
name: ToolName.GET_COLUMN_VALUES,
description:
"Returns the distinct values for a specified column in a model or source. Use this to understand the data distribution and possible values in a column.",
Expand All @@ -281,6 +285,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.EXECUTE_SQL,
description:
"Executes SQL queries against the database, returning processed results immediately. Use this to test queries and retrieve data from the database.",
Expand Down Expand Up @@ -310,6 +315,7 @@ This must be called first to get the projectRoot parameter needed for all other
]
: []),
{
namespace: "dbt",
name: ToolName.COMPILE_MODEL,
description:
"Converts a dbt model's Jinja SQL into raw SQL. Use this to inspect the generated SQL before executing it. Note: This does not validate if the SQL will run successfully.",
Expand All @@ -330,6 +336,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.COMPILE_QUERY,
description:
"Compile query, this will only convert the Jinja SQL to SQL, not determine if the SQL actually works. If the compilation succeeds, use the execute SQL and validate the data.",
Expand All @@ -353,6 +360,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.RUN_MODEL,
description:
"Executes a dbt model in the database. Use + for plusOperatorLeft to include parent models, and + for plusOperatorRight to include child models in the run.",
Expand All @@ -377,6 +385,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.BUILD_MODEL,
description:
"Builds a dbt model in the database. Use + for plusOperatorLeft to include parent models, and + for plusOperatorRight to include child models in the build.",
Expand All @@ -401,6 +410,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.BUILD_PROJECT,
description:
"Builds the dbt project, this will run seeds, models and all related tests",
Expand All @@ -421,6 +431,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.RUN_TEST,
description:
"Run an indivdual test based on the test name in the dbt manifest.",
Expand All @@ -443,6 +454,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.RUN_MODEL_TEST,
description:
"Run model tests, use this tool to run the existing tests defined for the dbt model",
Expand All @@ -465,6 +477,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.ADD_DBT_PACKAGES,
description:
"Add dbt package(s) to the project, the dbt package string should be in the form of packageName@version",
Expand All @@ -487,6 +500,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.INSTALL_DEPS,
description:
"Install dbt package dependencies based on the dbt projects's packages.yml file",
Expand All @@ -509,6 +523,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.GET_CHILDREN_MODELS,
description:
"Returns the list of models that depend on the specified model (its children). Use this to understand a model's downstream impact and lineage.",
Expand All @@ -533,6 +548,7 @@ This must be called first to get the projectRoot parameter needed for all other
},
},
{
namespace: "dbt",
name: ToolName.GET_PARENT_MODELS,
description:
"Returns the list of models that the specified model depends on (its parents). Use this to understand a model's upstream dependencies and lineage.",
Expand Down
1 change: 1 addition & 0 deletions src/mcp/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { z } from "zod";
export type ToolInput = z.infer<typeof ToolSchema.shape.inputSchema>;

export type McpTool = {
namespace: string;
name: string;
description: string;
inputSchema: ToolInput;
Expand Down
Loading