Skip to main content
Glama
TheAlchemist6

CodeCompass MCP

analyze_dependencies

Analyze GitHub repository dependencies to identify security vulnerabilities, version conflicts, and outdated packages for improved code reliability.

Instructions

📦 Comprehensive dependency analysis including external packages, internal dependencies, security vulnerabilities, and version conflicts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesGitHub repository URL
optionsNo

Implementation Reference

  • MCP tool handler function that parses arguments, delegates to GitHubService.analyzeDependencies, creates standardized response, and formats for MCP protocol.
    async function handleAnalyzeDependencies(args: any) {
      try {
        const { url, options = {} } = args;
        
        const dependencies = await githubService.analyzeDependencies(url);
        
        const response = createResponse(dependencies);
        return formatToolResponse(response);
      } catch (error) {
        const response = createResponse(null, error);
        return formatToolResponse(response);
      }
    }
  • Tool schema definition including input schema for parameters like repository URL and analysis options.
    {
      name: 'analyze_dependencies',
      description: '📦 Comprehensive dependency analysis including external packages, internal dependencies, security vulnerabilities, and version conflicts.',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'GitHub repository URL',
          },
          options: {
            type: 'object',
            properties: {
              include_dev_dependencies: {
                type: 'boolean',
                description: 'Include development dependencies',
                default: true,
              },
              include_security_scan: {
                type: 'boolean',
                description: 'Include security vulnerability scanning',
                default: true,
              },
              include_version_analysis: {
                type: 'boolean',
                description: 'Include version conflict analysis',
                default: true,
              },
              check_outdated: {
                type: 'boolean',
                description: 'Check for outdated packages',
                default: true,
              },
            },
          },
        },
        required: ['url'],
      },
    },
  • src/index.ts:236-240 (registration)
    Registers the list of available tools, including analyze_dependencies, for MCP ListTools requests.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: consolidatedTools,
      };
    });
  • Core helper method in GitHubService that fetches and parses dependency files (package.json, requirements.txt) to extract dependency information.
    async analyzeDependencies(url: string): Promise<DependencyInfo[]> {
      const dependencies: DependencyInfo[] = [];
      
      try {
        // Check for package.json
        try {
          const packageJson = await this.getFileContent(url, 'package.json');
          const pkg = JSON.parse(packageJson);
          
          // Add regular dependencies
          if (pkg.dependencies) {
            for (const [name, version] of Object.entries(pkg.dependencies)) {
              dependencies.push({
                name,
                version: version as string,
                type: 'dependency',
                source: 'package.json',
              });
            }
          }
          
          // Add dev dependencies
          if (pkg.devDependencies) {
            for (const [name, version] of Object.entries(pkg.devDependencies)) {
              dependencies.push({
                name,
                version: version as string,
                type: 'devDependency',
                source: 'package.json',
              });
            }
          }
          
          // Add peer dependencies
          if (pkg.peerDependencies) {
            for (const [name, version] of Object.entries(pkg.peerDependencies)) {
              dependencies.push({
                name,
                version: version as string,
                type: 'peerDependency',
                source: 'package.json',
              });
            }
          }
        } catch (error) {
          // package.json not found, continue with other dependency files
        }
        
        // Check for requirements.txt
        try {
          const requirementsTxt = await this.getFileContent(url, 'requirements.txt');
          const lines = requirementsTxt.split('\n').filter(line => line.trim() && !line.startsWith('#'));
          
          for (const line of lines) {
            const match = line.match(/^([^=><]+)([=><]=?.*)?$/);
            if (match) {
              dependencies.push({
                name: match[1].trim(),
                version: match[2] || '*',
                type: 'dependency',
                source: 'requirements.txt',
              });
            }
          }
        } catch (error) {
          // requirements.txt not found
        }
        
        // Add more dependency file parsers as needed (Gemfile, Cargo.toml, etc.)
        
      } catch (error: any) {
        console.error('Error analyzing dependencies:', error.message);
      }
      
      return dependencies;
    }

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/TheAlchemist6/codecompass-mcp'

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