MCP HubMCP Hub
스킬 목록으로 돌아가기

analyze-codebase-for-mcp

pjt222
업데이트됨 2 days ago
7 조회
17
2
17
GitHub에서 보기
메타wordaiapimcpdesigndata

정보

이 스킬은 코드베이스를 분석하여 Model Context Protocol(MCP) 도구로 노출할 수 있는 함수, API, 데이터 소스를 식별하고 구조화된 명세서를 생성합니다. MCP 서버 계획 수립 시, AI 접근 가능한 도구 인터페이스를 위해 코드베이스를 감사할 때, 또는 기존 기능과 현재 MCP 노출 범위를 비교할 때 사용됩니다. 분석은 도구 변환에 적합한 함수, REST 엔드포인트, CLI 명령어, 데이터 접근 지점에 중점을 둡니다.

빠른 설치

Claude Code

추천
기본
npx skills add pjt222/agent-almanac -a claude-code
플러그인 명령대체
/plugin add https://github.com/pjt222/agent-almanac
Git 클론대체
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/analyze-codebase-for-mcp

Claude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요

문서

Analyze Codebase for MCP

Scan codebase → fns, REST endpoints, CLI cmds, data access candidates → MCP tool exposure → structured tool spec doc.

Use When

  • Plan MCP server existing project → know what to expose
  • Audit codebase pre-AI-tool-surface wrap
  • Compare codebase capability vs MCP exposed
  • Generate tool spec → hand to scaffold-mcp-server
  • Evaluate 3rd-party lib worth wrapping

In

  • Required: Path to codebase root
  • Required: Target lang(s) (TS, Python, R, Go)
  • Optional: Existing MCP server code → gap analysis
  • Optional: Domain focus ("data analysis", "file ops", "API integration")
  • Optional: Max tools to recommend (default: 20)

Do

Step 1: Scan Structure

1.1. Glob → dir tree, src dirs:

  • src/**/*.{ts,js,py,R,go,rs} → src files
  • **/routes/**, **/api/**, **/controllers/** → endpoints
  • **/cli/**, **/commands/** → CLI entries
  • **/package.json, **/setup.py, **/DESCRIPTION → dep metadata

1.2. Categorize by role:

  • Entry: main files, route handlers, CLI cmds
  • Core logic: business fns, algos, data transformers
  • Data access: DB queries, file I/O, API clients
  • Utilities: helpers, formatters, validators

1.3. Count files, LOC, exported symbols → gauge size.

Categorized inventory w/ role annotations.

If err: Too large (>10K files) → narrow via domain focus. No src found → verify root path + lang params.

Step 2: Identify Fns + Endpoints

2.1. Grep exported fns + public APIs:

  • TS/JS: export (async )?function, export default, module.exports
  • Python: fns no _ prefix, @app.route, @router
  • R: NAMESPACE or #' @export roxygen
  • Go: capitalized fn names (exported by convention)

2.2. Per candidate extract:

  • Name: fn/endpoint
  • Signature: params w/ types + defaults
  • Return type
  • Docs: docstrings, JSDoc, roxygen, godoc
  • Location: file path + line

2.3. REST APIs, also extract:

  • HTTP method + route pattern
  • Req body schema
  • Res shape
  • Auth reqs

2.4. Sort by potential utility (public, documented, well-typed first).

20-100 candidates w/ extracted metadata.

If err: Few candidates → broaden → include internal that could be public. Sparse docs → flag as risk.

Step 3: Evaluate MCP Suitability

3.1. Per candidate → MCP tool criteria:

  • In contract clarity: params well-typed + documented? JSON Schema describable?
  • Out predictability: structured (JSON-serializable)? Consistent shape?
  • Side effects: modifies state (files, DB, external)? Must be labeled.
  • Idempotency: safe to retry? Non-idempotent → explicit warn.
  • Exec time: completes <30s? Long-running → async patterns.
  • Err handling: structured errs or silent fail?

3.2. Score 1-5:

  • 5: Pure fn, typed I/O, documented, fast, no side effects
  • 4: Well-typed, documented, minor side effects (logging)
  • 3: Reasonable I/O, needs wrapping (raw objects)
  • 2: Significant side effects or unclear, substantial adaptation
  • 1: Not suitable no major refactor

3.3. Filter ≥3. Flag score-2 → "future candidates" needing refactor.

Scored + filtered list w/ suitability rationale.

If err: Most <3 → codebase needs refactor pre-MCP. Doc gaps → recommend (add types, extract pure fns, wrap side effects).

Step 4: Design Tool Specs

4.1. Per selected (≥3) draft spec:

- name: tool_name
  description: >
    One-line description of what the tool does.
  source_function: module.function_name
  source_file: src/path/to/file.ts:42
  parameters:
    param_name:
      type: string | number | boolean | object | array
      description: What this parameter controls
      required: true | false
      default: value_if_optional
  returns:
    type: string | object | array
    description: What the tool returns
  side_effects:
    - description of any side effect
  estimated_latency: fast | medium | slow
  suitability_score: 5

4.2. Group logical categories ("Data Queries", "File Ops", "Analysis", "Config").

4.3. Identify deps between tools ("list_datasets" before "query_dataset").

4.4. Need wrappers?

  • Simplify complex param objects → flat in
  • Convert raw returns → structured text/JSON
  • Safety guards (read-only wrappers for DB fns)

Complete YAML spec w/ categories, deps, wrapper notes.

If err: Ambiguous → Step 2 → more src detail. Param types uninferable → flag manual review.

Step 5: Generate Tool Spec Doc

5.1. Final doc sections:

  • Summary: Codebase overview, lang, size, date
  • Recommended Tools: Full specs from Step 4, grouped
  • Future Candidates: Score-2 + refactor recs
  • Excluded: Score-1 + rationale
  • Dependencies: Tool dep graph
  • Impl Notes: Wrappers, auth, transport

5.2. Save mcp-tool-spec.yml (machine) + mcp-tool-spec.md (human).

5.3. Existing MCP server provided → gap analysis:

  • In spec, not impl
  • Impl, not in spec (stale)
  • Spec drift (impl diverges)

Complete doc → consumable by scaffold-mcp-server.

If err: >200 tools → split modules w/ cross-refs. No candidates → "readiness assessment" doc w/ refactor recs.

Check

  • All src files scanned
  • Candidates have names, signatures, returns
  • Each candidate scored + rationale
  • Tool specs complete param schemas w/ types
  • Side effects explicit per tool
  • Doc valid YAML (parseable)
  • Tool names follow MCP (snake_case, unique)
  • Categories + deps coherent
  • Gap analysis if existing MCP provided
  • Future candidates list refactor steps

Traps

  • Too many tools: AI works best 10-30 focused. Breadth > depth. Resist every public fn.
  • Ignore side effects: "Just reads" + logs/cache = still side effects. Audit Grep file writes, network, DB.
  • Assume type safety: Dynamic langs (Py, R, JS) may lack type annotations. Infer from usage, flag uncertainty.
  • Missing auth ctx: Fns working in authed web req may fail via MCP no session. Check implicit session cookies, JWT, env creds.
  • Over-engineer wrappers: 50-line wrapper → not good candidate. Prefer natural mapping.
  • Neglect err paths: MCP must return structured errs. Untyped exceptions → err-handling wrappers.
  • Conflate internal + external APIs: Internal helpers poor candidates. Focus external-consumption or boundary APIs.
  • Skip gap analysis: Existing MCP provided → always compare. No gap analysis → duplicate work or stale tools.

  • scaffold-mcp-server — use out spec → working MCP
  • build-custom-mcp-server — manual impl ref
  • configure-mcp-server — connect to Claude Code/Desktop
  • troubleshoot-mcp-connection — debug after deploy
  • review-software-architecture — arch review for tool surface
  • security-audit-codebase — audit pre-external exposure

GitHub 저장소

pjt222/agent-almanac
경로: i18n/caveman-ultra/skills/analyze-codebase-for-mcp
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

연관 스킬

content-collections

메타

이 스킬은 콘텐츠 콜렉션(Content Collections)을 위한 프로덕션 검증된 설정을 제공합니다. 콘텐츠 콜렉션은 Markdown/MDX 파일을 Zod 검증이 포함된 타입 안전한 데이터 콜렉션으로 변환해주는 TypeScript 최우선 도구입니다. 블로그, 문서 사이트 또는 콘텐츠 중심의 Vite + React 애플리케이션을 구축할 때 타입 안전성과 자동 콘텐츠 검증을 보장하기 위해 사용하세요. Vite 플러그인 구성과 MDX 컴파일부터 배포 최적화 및 스키마 검증에 이르기까지 모든 것을 다룹니다.

스킬 보기

polymarket

메타

이 스킬은 개발자들이 Polymarket 예측 시장 플랫폼을 활용한 애플리케이션을 구축할 수 있도록 지원하며, 거래 및 시장 데이터를 위한 API 통합 기능을 포함합니다. 또한 WebSocket을 통한 실시간 데이터 스트리밍을 제공하여 실시간 거래와 시장 활동을 모니터링할 수 있습니다. 이를 통해 거래 전략을 구현하거나 실시간 시장 업데이트를 처리하는 도구를 생성하는 데 활용할 수 있습니다.

스킬 보기

creating-opencode-plugins

메타

이 스킬은 개발자들이 명령어, 파일, LSP 작업 등 25개 이상의 이벤트 유형에 연결되는 OpenCode 플러그인을 만들 수 있도록 돕습니다. JavaScript/TypeScript 모듈을 위한 플러그인 구조, 이벤트 API 명세, 구현 패턴을 제공합니다. OpenCode AI 어시스턴트의 라이프사이클을 사용자 정의 이벤트 기반 로직으로 가로채거나, 모니터링하거나, 확장해야 할 때 사용하세요.

스킬 보기

sglang

메타

SGLang은 RadixAttention 프리픽스 캐싱을 활용하여 JSON, 정규식, 에이전트 워크플로우를 위한 고속 구조화 생성에 특화된 고성능 LLM 서빙 프레임워크입니다. 특히 반복되는 프리픽스가 있는 작업에서 상당히 빠른 추론 속도를 제공하여 복잡한 구조화 출력 및 다중 턴 대화에 이상적입니다. 제약 디코딩이 필요하거나 광범위한 프리픽스 공유가 있는 애플리케이션을 구축할 때는 vLLM과 같은 대안보다 SGLang을 선택하십시오.

스킬 보기