Skip to main content
Glama

analyze_local_project

Analyze local project directories to detect stateful code patterns and receive guidance for migrating to stateless architectures in .NET and Java applications.

Instructions

Analyze a local project directory for stateful code patterns

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesAbsolute path to project directory

Implementation Reference

  • The execute function implements the core logic: validates project path, zips the directory using projectZipper, calls the Statelessor API via apiClient, formats the result, handles errors, and cleans up the temporary ZIP file.
    async execute(args) {
      let zipFilePath = null;
    
      try {
        const { projectPath } = args;
    
        // Validate project path
        const stats = await fs.stat(projectPath);
        if (!stats.isDirectory()) {
          throw new Error('Project path must be a directory');
        }
    
        // ZIP the project
        zipFilePath = await projectZipper.zipProject(projectPath);
    
        // Call Statelessor API
        const result = await apiClient.analyzeLocalProject(zipFilePath);
    
        // Format result for Amazon Q
        return {
          content: [
            {
              type: 'text',
              text: resultFormatter.formatAnalysisResult(result),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error analyzing local project: ${error.message}`,
            },
          ],
          isError: true,
        };
      } finally {
        // Cleanup ZIP file
        if (zipFilePath) {
          try {
            await fs.unlink(zipFilePath);
          } catch (err) {
            console.error('Failed to cleanup ZIP file:', err);
          }
        }
      }
    },
  • The tool definition object, including name, description, and inputSchema specifying the required 'projectPath' parameter.
    definition: {
      name: 'analyze_local_project',
      description: 'Analyze a local project directory for stateful code patterns',
      inputSchema: {
        type: 'object',
        properties: {
          projectPath: {
            type: 'string',
            description: 'Absolute path to project directory',
          },
        },
        required: ['projectPath'],
      },
    },
  • mcp-server.js:57-58 (registration)
    Registration in the MCP server switch statement: dispatches tool calls to analyzeLocalTool.execute.
    case 'analyze_local_project':
      return await analyzeLocalTool.execute(args);
  • mcp-server.js:42-42 (registration)
    Tool definition registered in the ListToolsRequestHandler response.
    analyzeLocalTool.definition,
  • API client method that sends the ZIP file to the Statelessor /analyze endpoint for processing.
    async analyzeLocalProject(zipFilePath) {
      const requestId = this.generateRequestId();
      
      try {
        const formData = new FormData();
        formData.append('type', 'zip');
        formData.append('zipFile', fs.createReadStream(zipFilePath));  // Changed from 'file' to 'zipFile'
    
        const response = await this.client.post('/analyze', formData, {
          headers: {
            'X-Request-ID': requestId,
            ...formData.getHeaders(),
          },
        });
    
        return response.data;
      } catch (error) {
        throw this.handleError(error, 'analyzeLocalProject');
      }
    }

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/aloksinghGIT/statelessor-mcp'

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