Skip to main content
Glama

scan_dependencies

Identify and extract project dependency details from pyproject.toml files. Provides JSON output with specifications and metadata, enabling accurate AI-assisted documentation and coding support.

Instructions

Scan project dependencies from pyproject.toml

Args: project_path: Path to project directory (defaults to current directory)

Returns: JSON with dependency specifications and project metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core handler function for the 'scan_dependencies' MCP tool. It validates the project path, parses dependencies using PyProjectParser, handles errors, tracks metrics, and returns formatted results or error responses. Registered via @mcp.tool decorator.
    @mcp.tool
    async def scan_dependencies(project_path: str | None = None) -> dict[str, Any]:
        """
        Scan project dependencies from pyproject.toml
    
        Args:
            project_path: Path to project directory (defaults to current directory)
    
        Returns:
            JSON with dependency specifications and project metadata
        """
        from .observability import get_metrics_collector, track_request
    
        async with track_request("scan_dependencies") as metrics:
            if parser is None:
                get_metrics_collector().finish_request(
                    metrics.request_id,
                    success=False,
                    error_type="ServiceNotInitialized",
                )
                return {
                    "success": False,
                    "error": {
                        "message": "Parser not initialized",
                        "suggestion": "Try again or restart the MCP server",
                        "severity": "critical",
                        "code": "service_not_initialized",
                        "recoverable": False,
                    },
                }
    
            try:
                # Validate project path if provided
                if project_path is not None:
                    path = InputValidator.validate_project_path(project_path)
                else:
                    path = Path.cwd()
                logger.info("Scanning dependencies", project_path=str(path))
    
                result = await parser.parse_project(path)
    
                # Record successful metrics
                get_metrics_collector().finish_request(
                    metrics.request_id,
                    success=True,
                    dependency_count=result.successful_deps,
                )
    
                # Use ResponseFormatter for consistent error formatting
                return ResponseFormatter.format_scan_response(result)
    
            except ProjectParsingError as e:
                formatted_error = ErrorFormatter.format_exception(e)
                get_metrics_collector().finish_request(
                    metrics.request_id,
                    success=False,
                    error_type="ProjectParsingError",
                )
                return {
                    "success": False,
                    "error": {
                        "message": formatted_error.message,
                        "suggestion": formatted_error.suggestion,
                        "severity": formatted_error.severity.value,
                        "code": formatted_error.error_code,
                        "recoverable": formatted_error.recoverable,
                    },
                }
            except Exception as e:
                formatted_error = ErrorFormatter.format_exception(e)
                get_metrics_collector().finish_request(
                    metrics.request_id,
                    success=False,
                    error_type=type(e).__name__,
                )
                return {
                    "success": False,
                    "error": {
                        "message": formatted_error.message,
                        "suggestion": formatted_error.suggestion,
                        "severity": formatted_error.severity.value,
                        "code": formatted_error.error_code,
                        "recoverable": formatted_error.recoverable,
                    },
                }
  • The @mcp.tool decorator registers the scan_dependencies function as an MCP tool in the FastMCP server.
    @mcp.tool
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions scanning dependencies and returning JSON, but fails to detail critical aspects like error handling (e.g., if pyproject.toml is missing), performance implications, or any side effects. This leaves significant gaps for an agent to understand the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with the core purpose stated first followed by structured sections for args and returns. There's minimal waste, though the 'Args:' and 'Returns:' labels could be slightly more integrated into the flow.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (scanning dependencies), no annotations, and an output schema present (which handles return values), the description is partially complete. It covers the basic operation and parameters but lacks details on errors, dependencies on external files, or integration with sibling tools, leaving room for improvement.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must compensate. It adds meaning by explaining that 'project_path' defaults to the current directory and specifies the file type ('pyproject.toml'), which clarifies beyond the schema's generic 'Project Path' title. However, it doesn't cover parameter constraints or format details, keeping the score at baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Scan project dependencies') and the resource ('from pyproject.toml'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_package_docs' or 'refresh_cache', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description lacks context about prerequisites, such as whether the project must have a pyproject.toml file, or comparisons to siblings like 'get_package_docs' for documentation retrieval.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/bradleyfay/autodoc-mcp'

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