project_execute_analysis
Analyze project data by executing Python code generated from natural language requests to extract insights and metrics.
Instructions
Execute intelligent analysis on specific project instance with ultra-fast performance. Automatically generates Python code based on analysis request.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project identifier to execute analysis on | |
| analysisRequest | Yes | Natural language description of the analysis you want to perform (e.g., 'get network statistics', 'analyze node distribution', 'check link lengths') | |
| returnFormat | No | Format of results: summary (key metrics), detailed (comprehensive), raw (full data) | summary |
Implementation Reference
- src/index-backup.ts:826-868 (registration)MCP server.tool registration for 'project_execute_analysis', including input schema (Zod), description, and inline handler function that delegates execution to projectManager.executeProjectAnalysis and formats the response.server.tool( "project_execute_analysis", "Execute analysis on specific project instance with ultra-fast performance", { projectId: z.string().describe("Project identifier to execute analysis on"), analysisCode: z.string().describe("Python code to execute on the project instance"), description: z.string().optional().describe("Optional description of the analysis") }, async ({ projectId, analysisCode, description }) => { try { const result = await projectManager.executeProjectAnalysis(projectId, analysisCode, description); if (result.success) { return { content: [ { type: "text", text: `š **Analisi Completata** (${result.projectInfo?.projectName})\n\nā” **Tempo esecuzione:** ${result.executionTimeMs}ms\n\nš **Risultati:**\n\`\`\`json\n${JSON.stringify(result.result, null, 2)}\n\`\`\`` } ] }; } else { return { content: [ { type: "text", text: `ā **Errore Analisi**\n\n${result.error}` } ] }; } } catch (error) { return { content: [ { type: "text", text: `ā **Errore:** ${error instanceof Error ? error.message : String(error)}` } ] }; } } );
- src/project-instance-manager.ts:138-155 (handler)Core handler method in ProjectInstanceManager that retrieves the project instance, validates it's active, and delegates to executeOnInstance for executing the analysis code via the instance's controller.public async executeProjectAnalysis(projectId: string, analysisCode: string, description?: string): Promise<{ success: boolean; result?: any; error?: string; executionTimeMs?: number; projectInfo?: any; }> { const instance = this.projectInstances.get(projectId); if (!instance || !instance.isActive) { return { success: false, error: `Instance '${projectId}' is not active. Use 'project_start_instance' to start it first.` }; } return this.executeOnInstance(instance, analysisCode, description); }
- Private helper method that updates last used time, executes the analysis code using the project instance's controller.executeCustomCode, and packages the result with project info.private async executeOnInstance(instance: ProjectInstance, analysisCode: string, description?: string): Promise<{ success: boolean; result?: any; error?: string; executionTimeMs?: number; projectInfo?: any; }> { try { instance.lastUsed = Date.now(); const result = await instance.controller.executeCustomCode(analysisCode, description); return { success: result.success, result: result.result, error: result.error, executionTimeMs: result.executionTimeMs, projectInfo: { projectName: instance.config.name, projectId: instance.config.name.toLowerCase(), stats: instance.stats } }; } catch (error) { return { success: false, error: error instanceof Error ? error.message : String(error) }; } }