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
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | No |
Implementation Reference
- src/autodoc_mcp/main.py:116-201 (handler)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, }, }
- src/autodoc_mcp/main.py:116-116 (registration)The @mcp.tool decorator registers the scan_dependencies function as an MCP tool in the FastMCP server.@mcp.tool