Skip to content

[Feature Request] Support Standalone CLI Mode for Direct Integration and Token Efficiency #500

@DerekJi

Description

@DerekJi

Love this amazing project! It’s one of the best implementations of code graph indexing for AI agents.

Currently,  codegraph  is primarily designed as an MCP (Model Context Protocol) server. While MCP is great for Claude, I’ve found a few limitations when trying to integrate it into custom coding agents (e.g., custom Python-based agents or other IDE extensions):

1. Token Overhead: The MCP JSON-RPC layer and the current verbosity of tool outputs can lead to significant token consumption, especially during frequent tool calls.

2. Integration Complexity: For developers building their own agents, setting up a full MCP client just to query code relationships adds unnecessary architectural overhead.

3. Cold Start: Launching the MCP server for quick, one-off queries can be slower than a direct CLI call.

Proposed Feature:

I would like to propose adding a Standalone CLI Mode that allows users to interact with the indexed graph directly via the terminal.

Suggested Commands:

  •  codegraph index [path] : (Already exists in some form) To scan and update the SQLite database.
  •  codegraph query --file  : Output a high-level summary of a file's dependencies (imports/exports/calls) in a concise Markdown format optimized for LLM context.
  •  codegraph search  : Quickly find the definition and references of a specific class/function across the codebase.

Basically the commands should be same as theMCP endpoints.

Why this is valuable:

  • Token Efficiency: We can implement "compressed" outputs specifically for CLI queries, allowing custom agents to grab only the "map" they need.
  • Universal Use: It would make  codegraph  a universal code-mapping tool that can be used by any script (Python, Bash, etc.) without requiring MCP.

If you are open to this, I would be happy to contribute a PR to help implement the basic CLI structure (perhaps using  commander  or  yargs ).

What do you think?

 

This also aligns with the token optimization discussions in #185.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions