Skip to main content
Glama

Code Scanner Server

by Ixe1

code-scanner-server

コード ファイルの定義 (クラス、関数など) をスキャンし、.gitignore を尊重し、行番号を提供し、LLM 対応形式 (XML/Markdown) を出力する CLI ツールおよび MCP サーバー。

このプロジェクトは、TypeScriptとNode.jsで構築された多用途のコードスキャンツールを提供します。Tree-sitter解析ライブラリを活用してソースコードを解析し、構造情報を抽出します。コマンドラインインターフェース(CLI)ツールとしても、MCP(Model Context Protocol)サーバーとしても動作します。

**注:**このツールは現在開発中です。コア機能は動作しますが、一部の機能や特定の言語パーサーは完全にテストされておらず、バグや制限が含まれている可能性があります。

特徴

  • **コード定義の抽出:**関数、クラス、変数、インターフェース、メソッドなどを識別します。
  • 多言語サポート: Tree-sitter を介して JavaScript ( .js.jsx )、TypeScript ( .ts.tsx )、C# ( .cs )、PHP ( .php )、CSS ( .css )、および Python ( .py ) を解析します。
  • .gitignore 対応: .gitignoreファイルで定義されたルールを自動的に尊重します。
  • **柔軟なフィルタリング:**定義タイプ、修飾子 ( publicprivate )、名前パターン (正規表現)、およびファイル パス パターンで結果をフィルタリングします。
  • 複数の出力形式: Markdown (デフォルト)、XML、または JSON で結果を生成します。
  • **設定可能な詳細レベル:**出力の詳細度: minimalstandard (デフォルト)、 detailed
  • **デュアル モード操作:**スタンドアロン CLI ツールとして、または統合された MCP サーバーとして実行します。

使用モード

1. コマンドラインインターフェース(CLI)

ターミナルから直接スキャナーを実行します。このモードでは、ターゲットのコードベースを指定する--directory引数が必要です。

基本的な使用方法:

node build/index.js --directory /path/to/your/codebase

一般的なオプション:

  • -d, --directory <path> : (必須) スキャンするディレクトリへの絶対パスまたは相対パス。
  • -p, --patterns <patterns...> : ファイル拡張子のglobパターン(例: "**/*.ts"``"**/*.js" )。デフォルトはJS、TSX、CS、PHP、CSS、PYファイルです。
  • -f, --format <format> : 出力形式( xmlmarkdownjson )。デフォルト: markdown
  • -l, --detail <level> : 詳細レベル( minimalstandarddetailed )。デフォルト: standard
  • --include-types <types...> : 特定の定義タイプ (例: classmethod ) のみを含めます。
  • --exclude-types <types...> : 特定の定義タイプを除外します。
  • --include-modifiers <modifiers...> : 特定の修飾子 (例: public ) を持つ定義のみを含めます。
  • --exclude-modifiers <modifiers...> : 特定の修飾子を持つ定義を除外します。
  • --name-pattern <regex> : JavaScript 正規表現パターンに一致する定義を含めます。
  • --exclude-name-pattern <regex> : JavaScript 正規表現パターンに一致する定義を除外します。
  • --include-paths <paths...> : 含める追加のファイル パス パターン (glob)。
  • --exclude-paths <paths...> : 除外するファイル パス パターン (glob)。
  • -h, --help : すべてのオプションの詳細なヘルプ情報を表示します。

例 ( src内の TypeScript ファイルをスキャンし、詳細な JSON を出力する):

node build/index.js -d ./src -p "**/*.ts" -f json -l detailed

2. MCPサーバーモード( scan_codeツール)

--directory引数を指定せずに実行すると、ツールはMCPサーバーとして起動し、標準入出力を介してリクエストをリッスンします。これにより、AIアシスタントなどのMCPクライアントとの統合が可能になります。

  • ツール名: scan_code
  • **説明:**指定されたディレクトリでコード ファイルをスキャンし、指定されたフィルターに従って定義のリストを返します。
  • 入力スキーマ: CLIオプションに対応する引数を受け入れます。 directoryプロパティは必須です。
    { "type": "object", "properties": { "directory": { "type": "string", "description": "Absolute path to the directory to scan." }, "filePatterns": { "type": "array", "items": { "type": "string" }, "description": "Glob patterns for files.", "default": ["**/*.js", ..., "**/*.py"] }, "outputFormat": { "type": "string", "enum": ["xml", "markdown", "json"], "default": "markdown" }, "detailLevel": { "type": "string", "enum": ["minimal", "standard", "detailed"], "default": "standard" }, "includeTypes": { "type": "array", "items": { "type": "string" } }, "excludeTypes": { "type": "array", "items": { "type": "string" } }, "includeModifiers": { "type": "array", "items": { "type": "string" } }, "excludeModifiers": { "type": "array", "items": { "type": "string" } }, "namePattern": { "type": "string", "description": "Regex pattern for names." }, "excludeNamePattern": { "type": "string", "description": "Regex pattern to exclude names." }, "includePaths": { "type": "array", "items": { "type": "string" } }, "excludePaths": { "type": "array", "items": { "type": "string" } } }, "required": ["directory"] }
  • AI アシスタントでの使用例: 「ディレクトリ /path/to/project で code-scanner-server scan_code を使用して、xml 形式を出力します。」

インストール

  1. 前提条件: Node.js と npm がインストールされていることを確認してください。
  2. **クローン (オプション):**コードがない場合は、リポジトリをクローンします。
    # git clone <repository_url> # cd code-scanner-server
  3. 依存関係をインストールします:
    npm install
  4. ビルド: TypeScript コードをコンパイルします。
    npm run build
    これによりbuild/index.jsに実行可能な JavaScript ファイルが作成されます。

構成(MCP サーバー)

MCP サーバー モードを使用するには、MCP クライアントの構成ファイル (デスクトップ アプリの場合はclaude_desktop_config.json 、VS Code 拡張機能の場合はcline_mcp_settings.json ) に追加します。

重要:以下の例の/path/to/code-scanner-serverシステム上のこのプロジェクトのディレクトリへの絶対パスに置き換えてください。

例 ( claude_desktop_config.json / cline_mcp_settings.json ):

{ "mcpServers": { "code-scanner-server": { "command": "node", "args": [ "/absolute/path/to/your/code-scanner-server/build/index.js" // <-- Replace this path! (e.g., "C:\\Users\\YourUser\\Projects\\code-scanner-server\\build\\index.js" on Windows) ], "env": {}, "disabled": false, "autoApprove": [] // Add tool names here for auto-approval if desired } } }

変更を有効にするには、構成を変更した後、必ず MCP クライアント アプリケーション (IDE、デスクトップ アプリ) を再起動してください。

発達

  • **監視モード:**ソース ファイルが変更されたときにプロジェクトを自動的に再構築します。
    npm run watch
  • デバッグ(MCPモード): stdio経由のMCPサーバーのデバッグは複雑になる場合があります。MCP Inspectorツールを使用すると、デバッグが容易になります。
    npm run inspector
    これにより、Node.js インスペクターがアタッチされた状態でサーバーが起動し、デバッグ ツール (Chrome DevTools など) に接続するための URL が提供されます。

謝辞

このプロジェクトは、主に Visual Studio Code の Roo Code 拡張機能を介してアクセスした Google の Gemini 2.5 Pro モデルを使用して、AI の支援を受けて大幅に開発されました。

ライセンス

このプロジェクトは、GNU General Public License v3.0 に基づいてライセンスされています。詳細については、 LICENSEファイルを参照してください。

-
security - not tested
-
license - not tested
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

コードベースをスキャンして、柔軟なフィルタリング オプションを使用して構造情報 (クラス、関数など) を抽出し、LLM に適した形式で出力する MCP サーバーです。

  1. 特徴
    1. 使用モード
      1. コマンドラインインターフェース(CLI)
      2. MCPサーバーモード( scan_codeツール)
    2. インストール
      1. 構成(MCP サーバー)
        1. 発達
          1. 謝辞
            1. ライセンス

              Related MCP Servers

              • A
                security
                A
                license
                A
                quality
                A MCP server for managing and storing code snippets in various programming languages, allowing users to create, list, and delete snippets via a standardized interface.
                Last updated -
                3
                4
                JavaScript
                MIT License
              • -
                security
                A
                license
                -
                quality
                An MCP server that provides tools to load and fetch documentation from any llms.txt source, giving users full control over context retrieval for LLMs in IDE agents and applications.
                Last updated -
                177
                Python
                MIT License
                • Apple
              • -
                security
                A
                license
                -
                quality
                A MCP server that transforms code repositories from GitHub, GitLab, or local directories into LLM-friendly formats, preserving context and structure for better AI processing.
                Last updated -
                1
                Python
                Apache 2.0
              • -
                security
                F
                license
                -
                quality
                An MCP server that implements a structured workflow for LLM-based coding, guiding development through feature clarification, documentation generation, phased implementation, and progress tracking.
                Last updated -
                8
                TypeScript
                • Apple

              View all related MCP servers

              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/Ixe1/code-scanner-server'

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