Skip to main content
Glama
NiclasOlofsson

DBT Core MCP Server

get_project_info

Retrieve dbt project details and run diagnostics to validate environment and connection settings.

Instructions

Get information about the dbt project with optional diagnostics.

Args: run_debug: Run dbt debug to validate environment and test connection (default: True)

Returns: Dictionary with project information and diagnostic results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
run_debugNo

Implementation Reference

  • Main handler function that executes the tool logic: retrieves project info from manifest, adds paths and status, optionally runs 'dbt debug' for diagnostics and parses connection status.
    async def toolImpl_get_project_info(self, run_debug: bool = True) -> dict[str, Any]:
        """Implementation for get_project_info tool."""
        # Get project info from manifest
        info = self.manifest.get_project_info()  # type: ignore
        info["project_dir"] = str(self.project_dir)
        info["profiles_dir"] = self.profiles_dir
        info["status"] = "ready"
    
        # Run full dbt debug if requested (default behavior)
        if run_debug:
            debug_result_obj = await self.runner.invoke(["debug"])  # type: ignore
    
            # Convert DbtRunnerResult to dictionary
            debug_result = {
                "success": debug_result_obj.success,
                "output": debug_result_obj.stdout if debug_result_obj.stdout else "",
            }
    
            # Parse the debug output
            diagnostics: dict[str, Any] = {
                "command_run": "dbt debug",
                "success": debug_result.get("success", False),
                "output": debug_result.get("output", ""),
            }
    
            # Extract connection status from output
            output = str(debug_result.get("output", ""))
            if "Connection test: [OK connection ok]" in output or "Connection test: OK" in output:
                diagnostics["connection_status"] = "ok"
            elif "Connection test: [ERROR" in output or "Connection test: FAIL" in output:
                diagnostics["connection_status"] = "failed"
            else:
                diagnostics["connection_status"] = "unknown"
    
            info["diagnostics"] = diagnostics
    
        return info
  • FastMCP tool registration decorator that binds the tool name 'get_project_info' to the implementation method, including docstring for tool description and parameters.
    @self.app.tool()
    async def get_project_info(
        ctx: Context,
        run_debug: bool = True,
    ) -> dict[str, Any]:
        """Get information about the dbt project with optional diagnostics.
    
        Args:
            run_debug: Run `dbt debug` to validate environment and test connection (default: True)
    
        Returns:
            Dictionary with project information and diagnostic results
        """
        await self._ensure_initialized_with_context(ctx)
        return await self.toolImpl_get_project_info(run_debug)
  • Helper method in ManifestLoader that extracts and counts project metadata (name, version, adapter, resource counts) from the loaded manifest.json.
    def get_project_info(self) -> dict[str, Any]:
        """
        Get high-level project information from the manifest.
    
        Returns:
            Dictionary with project metadata
        """
        if not self._manifest:
            raise RuntimeError("Manifest not loaded. Call load() first.")
    
        metadata: dict[str, Any] = self._manifest.get("metadata", {})  # type: ignore[assignment]
    
        # Count resources directly from manifest
        nodes = self._manifest.get("nodes", {})
        model_count = sum(1 for node in nodes.values() if isinstance(node, dict) and node.get("resource_type") == "model")
        source_count = len(self._manifest.get("sources", {}))
    
        return {
            "project_name": metadata.get("project_name", ""),
            "dbt_version": metadata.get("dbt_version", ""),
            "adapter_type": metadata.get("adapter_type", ""),
            "generated_at": metadata.get("generated_at", ""),
            "model_count": model_count,
            "source_count": source_count,
        }

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/NiclasOlofsson/dbt-core-mcp'

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