Skip to main content
Glama

scan_project_dirs

Scans project directories to locate package.json files and identify available development scripts for npm run dev processes.

Instructions

プロジェクト内のpackage.jsonとdevスクリプトを検索

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main asynchronous handler function for the 'scan_project_dirs' tool. It creates a ProjectScanner instance, scans for projects with dev scripts, formats the results as JSON (including project details like directory, name, dev script, env file, priority, and top dependencies), handles empty results and errors gracefully.
    export async function scanProjectDirs(): Promise<string> { try { logger.info('Scanning for project directories'); const scanner = new ProjectScanner(); const projects = await scanner.scanForProjects(); if (projects.length === 0) { return JSON.stringify({ success: false, message: 'devスクリプトが定義されたpackage.jsonが見つかりませんでした', projects: [] }); } const result = { success: true, message: `${projects.length}個のプロジェクトが見つかりました`, projects: projects.map(project => ({ directory: project.directory, name: project.packageJson.name || 'Unnamed Project', devScript: project.packageJson.scripts?.dev, hasEnvFile: !!project.envPath, envPath: project.envPath, priority: project.priority, dependencies: Object.keys({ ...project.packageJson.dependencies, ...project.packageJson.devDependencies }).slice(0, 5) // Show first 5 dependencies })) }; logger.info(`Found ${projects.length} projects with dev scripts`); return JSON.stringify(result, null, 2); } catch (error) { logger.error('Failed to scan project directories', { error }); return JSON.stringify({ success: false, message: `スキャンエラー: ${error}`, projects: [] }); } }
  • The Tool schema definition specifying the name, description, and empty input schema (no parameters required).
    export const scanProjectDirsSchema: Tool = { name: 'scan_project_dirs', description: 'プロジェクト内のpackage.jsonとdevスクリプトを検索', inputSchema: { type: 'object', properties: {}, additionalProperties: false } };
  • src/index.ts:127-135 (registration)
    Registration and dispatch of the tool handler in the main CallToolRequestSchema switch statement. Executes scanProjectDirs() and wraps the result in the required MCP response format.
    case 'scan_project_dirs': return { content: [ { type: 'text', text: await scanProjectDirs(), }, ], };
  • src/index.ts:55-65 (registration)
    Registration of the tool schema in the tools array used by the ListToolsRequestSchema handler to advertise available tools.
    const tools = [ scanProjectDirsSchema, startDevServerSchema, getDevStatusSchema, getDevLogsSchema, stopDevServerSchema, restartDevServerSchema, getHealthStatusSchema, recoverFromStateSchema, autoRecoverSchema, ];
  • Dependency mapping for the tool, specifying that 'scan_project_dirs' requires 'projectContext' service to be initialized before execution.
    export const SERVICE_DEPENDENCIES = { 'scan_project_dirs': ['projectContext'], 'start_dev_server': ['stateManager'], 'get_dev_status': ['stateManager'], 'get_dev_logs': ['stateManager'], 'stop_dev_server': ['stateManager'], 'restart_dev_server': ['stateManager'], 'get_health_status': ['healthChecker'], 'recover_from_state': ['stateManager'], 'auto_recover': ['stateManager', 'healthChecker'] } as const;

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/masamunet/npm-dev-mcp'

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