Skip to main content
Glama
dh1789

My First MCP

by dh1789

analyze_dependencies

Analyze package.json files to identify and report project dependencies, including development dependencies when specified.

Instructions

프로젝트의 package.json을 분석하여 의존성 정보를 제공합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes분석할 프로젝트 경로 (package.json이 있는 디렉토리)
includeDevDepsNo개발 의존성 포함 여부. 기본값: true

Implementation Reference

  • Core handler function that parses package.json to extract project name, version, description, production dependencies, optional devDependencies, and scripts.
    export function analyzeDependencies(
      targetPath: string,
      options: DependencyOptions = {}
    ): DependencyResult {
      const { includeDevDeps = true } = options;
    
      try {
        const packagePath = path.join(targetPath, "package.json");
    
        if (!fs.existsSync(packagePath)) {
          return {
            success: false,
            error: `package.json을 찾을 수 없습니다: ${packagePath}`,
          };
        }
    
        const content = fs.readFileSync(packagePath, "utf-8");
        const pkg = JSON.parse(content);
    
        const result: DependencyResult = {
          success: true,
          name: pkg.name,
          version: pkg.version,
          description: pkg.description,
        };
    
        // 프로덕션 의존성
        if (pkg.dependencies) {
          result.dependencies = Object.entries(pkg.dependencies).map(
            ([name, version]) => ({
              name,
              version: version as string,
            })
          );
        }
    
        // 개발 의존성
        if (includeDevDeps && pkg.devDependencies) {
          result.devDependencies = Object.entries(pkg.devDependencies).map(
            ([name, version]) => ({
              name,
              version: version as string,
            })
          );
        }
    
        // 스크립트
        if (pkg.scripts) {
          result.scripts = Object.entries(pkg.scripts).map(([name, command]) => ({
            name,
            command: command as string,
          }));
        }
    
        return result;
      } catch (err) {
        return {
          success: false,
          error: err instanceof Error ? err.message : String(err),
        };
      }
    }
  • src/index.ts:466-516 (registration)
    Registers the analyze_dependencies tool with the MCP server, including description, Zod input schema, and wrapper handler that formats the output.
    server.tool(
      "analyze_dependencies",
      "프로젝트의 package.json을 분석하여 의존성 정보를 제공합니다.",
      {
        path: z.string().describe("분석할 프로젝트 경로 (package.json이 있는 디렉토리)"),
        includeDevDeps: z
          .boolean()
          .optional()
          .describe("개발 의존성 포함 여부. 기본값: true"),
      },
      async ({ path: targetPath, includeDevDeps }) => {
        const result = analyzeDependencies(targetPath, { includeDevDeps });
    
        if (!result.success) {
          return {
            content: [{ type: "text", text: `오류: ${result.error}` }],
            isError: true,
          };
        }
    
        let text = `📦 ${result.name} v${result.version}\n`;
        if (result.description) {
          text += `📝 ${result.description}\n`;
        }
    
        if (result.dependencies && result.dependencies.length > 0) {
          text += `\n🔗 프로덕션 의존성 (${result.dependencies.length}개):\n`;
          result.dependencies.forEach(dep => {
            text += `  - ${dep.name}: ${dep.version}\n`;
          });
        }
    
        if (result.devDependencies && result.devDependencies.length > 0) {
          text += `\n🛠️ 개발 의존성 (${result.devDependencies.length}개):\n`;
          result.devDependencies.forEach(dep => {
            text += `  - ${dep.name}: ${dep.version}\n`;
          });
        }
    
        if (result.scripts && result.scripts.length > 0) {
          text += `\n📜 스크립트 (${result.scripts.length}개):\n`;
          result.scripts.forEach(script => {
            text += `  - ${script.name}: ${script.command}\n`;
          });
        }
    
        return {
          content: [{ type: "text", text }],
        };
      }
    );
  • Zod input schema for the tool parameters: project path and optional includeDevDeps flag.
    {
      path: z.string().describe("분석할 프로젝트 경로 (package.json이 있는 디렉토리)"),
      includeDevDeps: z
        .boolean()
        .optional()
        .describe("개발 의존성 포함 여부. 기본값: true"),
    },
  • TypeScript interfaces defining input options, output result structure, and supporting types for dependencies and scripts.
    export interface DependencyInfo {
      name: string;
      version: string;
    }
    
    /**
     * 스크립트 정보
     */
    export interface ScriptInfo {
      name: string;
      command: string;
    }
    
    /**
     * 의존성 분석 옵션
     */
    export interface DependencyOptions {
      includeDevDeps?: boolean;
    }
    
    /**
     * 의존성 분석 결과
     */
    export interface DependencyResult {
      success: boolean;
      name?: string;
      version?: string;
      description?: string;
      dependencies?: DependencyInfo[];
      devDependencies?: DependencyInfo[];
      scripts?: ScriptInfo[];
      error?: string;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions analyzing package.json and providing dependency information, it doesn't describe what format the output takes, whether it's read-only or has side effects, error conditions, or performance characteristics. This leaves significant behavioral gaps for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point. There's no wasted language or unnecessary elaboration. It's appropriately sized for a tool with two parameters and clear basic functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is insufficient. It doesn't explain what the output looks like (dependency list format, structure, etc.), doesn't mention error handling for missing or invalid package.json files, and provides minimal behavioral context. Given the lack of structured metadata, the description should do more to compensate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema. It mentions analyzing package.json which implies the path parameter, but doesn't provide additional context about parameter usage or constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: analyzing package.json to provide dependency information. It specifies the resource (package.json) and the action (analyzing to provide information). However, it doesn't differentiate from sibling tools like analyze_structure, which might also analyze project files.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention any prerequisites, limitations, or when other tools like analyze_structure might be more appropriate. It simply states what the tool does without contextual usage information.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/dh1789/my-first-mcp'

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