Skip to main content
Glama
test_tool_names.py2.13 kB
from unittest.mock import patch from dbt_mcp.config.config import load_config from dbt_mcp.dbt_cli.binary_type import BinaryType from dbt_mcp.lsp.lsp_binary_manager import LspBinaryInfo from dbt_mcp.mcp.server import create_dbt_mcp from dbt_mcp.tools.tool_names import ToolName from dbt_mcp.tools.toolsets import proxied_tools async def test_tool_names_match_server_tools(env_setup): """Test that the ToolName enum matches the tools registered in the server.""" with ( env_setup( env_vars={ "DISABLE_DBT_CODEGEN": "false", } ), patch( "dbt_mcp.config.config.detect_binary_type", return_value=BinaryType.DBT_CORE ), patch( "dbt_mcp.config.config.dbt_lsp_binary_info", return_value=LspBinaryInfo(path="/path/to/lsp", version="1.0.0"), ), ): config = load_config(enable_proxied_tools=False) dbt_mcp = await create_dbt_mcp(config) # Get all tools from the server server_tools = await dbt_mcp.list_tools() # Manually adding proxied tools here because the server doesn't get them # in this unit test. server_tool_names = {tool.name for tool in server_tools} | { p.value for p in proxied_tools } enum_names = {n for n in ToolName.get_all_tool_names()} # This should not raise any errors if the enum is in sync if server_tool_names != enum_names: raise ValueError( f"Tool name mismatch:\n" f"In server but not in enum: {server_tool_names - enum_names}\n" f"In enum but not in server: {enum_names - server_tool_names}" ) # Double check that all enum values are strings for tool in ToolName: assert isinstance(tool.value, str), ( f"Tool {tool.name} value should be a string" ) def test_tool_names_no_duplicates(): """Test that there are no duplicate tool names in the enum.""" assert len(ToolName.get_all_tool_names()) == len(set(ToolName.get_all_tool_names()))

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dbt-labs/dbt-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server