#
tokens: 46647/50000 2/367 files (page 12/14)
lines: off (toggle) GitHub
raw markdown copy
This is page 12 of 14. Use http://codebase.md/shashankss1205/codegraphcontext?lines=false&page={x} to view the full context.

# Directory Structure

```
├── .github
│   └── workflows
│       ├── e2e-tests.yml
│       ├── post_discord_invite.yml
│       ├── test.yml
│       └── update-contributors.yml
├── .gitignore
├── CONTRIBUTING.md
├── contributors.md
├── docs
│   ├── docs
│   │   ├── architecture.md
│   │   ├── cli.md
│   │   ├── contributing_languages.md
│   │   ├── contributing.md
│   │   ├── cookbook.md
│   │   ├── core.md
│   │   ├── future_work.md
│   │   ├── images
│   │   │   ├── 1.png
│   │   │   ├── 11.png
│   │   │   ├── 12.png
│   │   │   ├── 13.png
│   │   │   ├── 14.png
│   │   │   ├── 16.png
│   │   │   ├── 19.png
│   │   │   ├── 2.png
│   │   │   ├── 20.png
│   │   │   ├── 21.png
│   │   │   ├── 22.png
│   │   │   ├── 23.png
│   │   │   ├── 24.png
│   │   │   ├── 26.png
│   │   │   ├── 28.png
│   │   │   ├── 29.png
│   │   │   ├── 3.png
│   │   │   ├── 30.png
│   │   │   ├── 31.png
│   │   │   ├── 32.png
│   │   │   ├── 33.png
│   │   │   ├── 34.png
│   │   │   ├── 35.png
│   │   │   ├── 36.png
│   │   │   ├── 38.png
│   │   │   ├── 39.png
│   │   │   ├── 4.png
│   │   │   ├── 40.png
│   │   │   ├── 41.png
│   │   │   ├── 42.png
│   │   │   ├── 43.png
│   │   │   ├── 44.png
│   │   │   ├── 5.png
│   │   │   ├── 6.png
│   │   │   ├── 7.png
│   │   │   ├── 8.png
│   │   │   ├── 9.png
│   │   │   ├── Indexing.gif
│   │   │   ├── tool_images
│   │   │   │   ├── 1.png
│   │   │   │   ├── 2.png
│   │   │   │   └── 3.png
│   │   │   └── Usecase.gif
│   │   ├── index.md
│   │   ├── installation.md
│   │   ├── license.md
│   │   ├── server.md
│   │   ├── tools.md
│   │   ├── troubleshooting.md
│   │   └── use_cases.md
│   ├── mkdocs.yml
│   └── site
│       ├── 404.html
│       ├── architecture
│       │   └── index.html
│       ├── assets
│       │   ├── images
│       │   │   └── favicon.png
│       │   ├── javascripts
│       │   │   ├── bundle.f55a23d4.min.js
│       │   │   ├── bundle.f55a23d4.min.js.map
│       │   │   ├── lunr
│       │   │   │   ├── min
│       │   │   │   │   ├── lunr.ar.min.js
│       │   │   │   │   ├── lunr.da.min.js
│       │   │   │   │   ├── lunr.de.min.js
│       │   │   │   │   ├── lunr.du.min.js
│       │   │   │   │   ├── lunr.el.min.js
│       │   │   │   │   ├── lunr.es.min.js
│       │   │   │   │   ├── lunr.fi.min.js
│       │   │   │   │   ├── lunr.fr.min.js
│       │   │   │   │   ├── lunr.he.min.js
│       │   │   │   │   ├── lunr.hi.min.js
│       │   │   │   │   ├── lunr.hu.min.js
│       │   │   │   │   ├── lunr.hy.min.js
│       │   │   │   │   ├── lunr.it.min.js
│       │   │   │   │   ├── lunr.ja.min.js
│       │   │   │   │   ├── lunr.jp.min.js
│       │   │   │   │   ├── lunr.kn.min.js
│       │   │   │   │   ├── lunr.ko.min.js
│       │   │   │   │   ├── lunr.multi.min.js
│       │   │   │   │   ├── lunr.nl.min.js
│       │   │   │   │   ├── lunr.no.min.js
│       │   │   │   │   ├── lunr.pt.min.js
│       │   │   │   │   ├── lunr.ro.min.js
│       │   │   │   │   ├── lunr.ru.min.js
│       │   │   │   │   ├── lunr.sa.min.js
│       │   │   │   │   ├── lunr.stemmer.support.min.js
│       │   │   │   │   ├── lunr.sv.min.js
│       │   │   │   │   ├── lunr.ta.min.js
│       │   │   │   │   ├── lunr.te.min.js
│       │   │   │   │   ├── lunr.th.min.js
│       │   │   │   │   ├── lunr.tr.min.js
│       │   │   │   │   ├── lunr.vi.min.js
│       │   │   │   │   └── lunr.zh.min.js
│       │   │   │   ├── tinyseg.js
│       │   │   │   └── wordcut.js
│       │   │   └── workers
│       │   │       ├── search.973d3a69.min.js
│       │   │       └── search.973d3a69.min.js.map
│       │   └── stylesheets
│       │       ├── main.2a3383ac.min.css
│       │       ├── main.2a3383ac.min.css.map
│       │       ├── palette.06af60db.min.css
│       │       └── palette.06af60db.min.css.map
│       ├── cli
│       │   └── index.html
│       ├── contributing
│       │   └── index.html
│       ├── contributing_languages
│       │   └── index.html
│       ├── cookbook
│       │   └── index.html
│       ├── core
│       │   └── index.html
│       ├── future_work
│       │   └── index.html
│       ├── images
│       │   ├── 1.png
│       │   ├── 11.png
│       │   ├── 12.png
│       │   ├── 13.png
│       │   ├── 14.png
│       │   ├── 16.png
│       │   ├── 19.png
│       │   ├── 2.png
│       │   ├── 20.png
│       │   ├── 21.png
│       │   ├── 22.png
│       │   ├── 23.png
│       │   ├── 24.png
│       │   ├── 26.png
│       │   ├── 28.png
│       │   ├── 29.png
│       │   ├── 3.png
│       │   ├── 30.png
│       │   ├── 31.png
│       │   ├── 32.png
│       │   ├── 33.png
│       │   ├── 34.png
│       │   ├── 35.png
│       │   ├── 36.png
│       │   ├── 38.png
│       │   ├── 39.png
│       │   ├── 4.png
│       │   ├── 40.png
│       │   ├── 41.png
│       │   ├── 42.png
│       │   ├── 43.png
│       │   ├── 44.png
│       │   ├── 5.png
│       │   ├── 6.png
│       │   ├── 7.png
│       │   ├── 8.png
│       │   ├── 9.png
│       │   ├── Indexing.gif
│       │   ├── tool_images
│       │   │   ├── 1.png
│       │   │   ├── 2.png
│       │   │   └── 3.png
│       │   └── Usecase.gif
│       ├── index.html
│       ├── installation
│       │   └── index.html
│       ├── license
│       │   └── index.html
│       ├── search
│       │   └── search_index.json
│       ├── server
│       │   └── index.html
│       ├── sitemap.xml
│       ├── sitemap.xml.gz
│       ├── tools
│       │   └── index.html
│       ├── troubleshooting
│       │   └── index.html
│       └── use_cases
│           └── index.html
├── images
│   ├── 1.png
│   ├── 11.png
│   ├── 12.png
│   ├── 13.png
│   ├── 14.png
│   ├── 16.png
│   ├── 19.png
│   ├── 2.png
│   ├── 20.png
│   ├── 21.png
│   ├── 22.png
│   ├── 23.png
│   ├── 24.png
│   ├── 26.png
│   ├── 28.png
│   ├── 29.png
│   ├── 3.png
│   ├── 30.png
│   ├── 31.png
│   ├── 32.png
│   ├── 33.png
│   ├── 34.png
│   ├── 35.png
│   ├── 36.png
│   ├── 38.png
│   ├── 39.png
│   ├── 4.png
│   ├── 40.png
│   ├── 41.png
│   ├── 42.png
│   ├── 43.png
│   ├── 44.png
│   ├── 5.png
│   ├── 6.png
│   ├── 7.png
│   ├── 8.png
│   ├── 9.png
│   ├── Indexing.gif
│   ├── tool_images
│   │   ├── 1.png
│   │   ├── 2.png
│   │   └── 3.png
│   └── Usecase.gif
├── LICENSE
├── MANIFEST.in
├── organizer
│   ├── CONTRIBUTING_LANGUAGES.md
│   ├── cookbook.md
│   ├── docs.md
│   ├── language_specific_nodes.md
│   ├── Tools_Exploration.md
│   └── troubleshoot.md
├── package-lock.json
├── pyproject.toml
├── README.md
├── scripts
│   ├── generate_lang_contributors.py
│   └── post_install_fix.sh
├── SECURITY.md
├── src
│   └── codegraphcontext
│       ├── __init__.py
│       ├── __main__.py
│       ├── cli
│       │   ├── __init__.py
│       │   ├── cli_helpers.py
│       │   ├── main.py
│       │   ├── setup_macos.py
│       │   └── setup_wizard.py
│       ├── core
│       │   ├── __init__.py
│       │   ├── database.py
│       │   ├── jobs.py
│       │   └── watcher.py
│       ├── prompts.py
│       ├── server.py
│       ├── tools
│       │   ├── __init__.py
│       │   ├── advanced_language_query_tool.py
│       │   ├── code_finder.py
│       │   ├── graph_builder.py
│       │   ├── languages
│       │   │   ├── c.py
│       │   │   ├── cpp.py
│       │   │   ├── go.py
│       │   │   ├── java.py
│       │   │   ├── javascript.py
│       │   │   ├── python.py
│       │   │   ├── ruby.py
│       │   │   ├── rust.py
│       │   │   └── typescript.py
│       │   ├── package_resolver.py
│       │   ├── query_tool_languages
│       │   │   ├── c_toolkit.py
│       │   │   ├── cpp_toolkit.py
│       │   │   ├── go_toolkit.py
│       │   │   ├── java_toolkit.py
│       │   │   ├── javascript_toolkit.py
│       │   │   ├── python_toolkit.py
│       │   │   ├── ruby_toolkit.py
│       │   │   ├── rust_toolkit.py
│       │   │   └── typescript_toolkit.py
│       │   └── system.py
│       └── utils
│           └── debug_log.py
├── tests
│   ├── __init__.py
│   ├── conftest.py
│   ├── sample_project
│   │   ├── advanced_calls.py
│   │   ├── advanced_classes.py
│   │   ├── advanced_classes2.py
│   │   ├── advanced_functions.py
│   │   ├── advanced_imports.py
│   │   ├── async_features.py
│   │   ├── callbacks_decorators.py
│   │   ├── circular1.py
│   │   ├── circular2.py
│   │   ├── class_instantiation.py
│   │   ├── cli_and_dunder.py
│   │   ├── complex_classes.py
│   │   ├── comprehensions_generators.py
│   │   ├── context_managers.py
│   │   ├── control_flow.py
│   │   ├── datatypes.py
│   │   ├── dynamic_dispatch.py
│   │   ├── dynamic_imports.py
│   │   ├── edge_cases
│   │   │   ├── comments_only.py
│   │   │   ├── docstring_only.py
│   │   │   ├── empty.py
│   │   │   ├── hardcoded_secrets.py
│   │   │   ├── long_functions.py
│   │   │   └── syntax_error.py
│   │   ├── function_chains.py
│   │   ├── generators.py
│   │   ├── import_reexports.py
│   │   ├── mapping_calls.py
│   │   ├── module_a.py
│   │   ├── module_b.py
│   │   ├── module_c
│   │   │   ├── __init__.py
│   │   │   ├── submodule1.py
│   │   │   └── submodule2.py
│   │   ├── namespace_pkg
│   │   │   └── ns_module.py
│   │   ├── pattern_matching.py
│   │   └── typing_examples.py
│   ├── sample_project_c
│   │   ├── cgc_sample
│   │   ├── include
│   │   │   ├── config.h
│   │   │   ├── math
│   │   │   │   └── vec.h
│   │   │   ├── module.h
│   │   │   ├── platform.h
│   │   │   └── util.h
│   │   ├── Makefile
│   │   ├── README.md
│   │   └── src
│   │       ├── main.c
│   │       ├── math
│   │       │   └── vec.c
│   │       ├── module.c
│   │       └── util.c
│   ├── sample_project_cpp
│   │   ├── class_features.cpp
│   │   ├── classes.cpp
│   │   ├── control_flow.cpp
│   │   ├── edge_cases.cpp
│   │   ├── enum_struct_union.cpp
│   │   ├── exceptions.cpp
│   │   ├── file_io.cpp
│   │   ├── function_chain.cpp
│   │   ├── function_chain.h
│   │   ├── function_types.cpp
│   │   ├── main.cpp
│   │   ├── main.exe
│   │   ├── namespaces.cpp
│   │   ├── raii_example.cpp
│   │   ├── README.md
│   │   ├── sample_project.exe
│   │   ├── stl_usage.cpp
│   │   ├── templates.cpp
│   │   └── types_variable_assignments.cpp
│   ├── sample_project_go
│   │   ├── advanced_types.go
│   │   ├── basic_functions.go
│   │   ├── embedded_composition.go
│   │   ├── error_handling.go
│   │   ├── generics.go
│   │   ├── go.mod
│   │   ├── goroutines_channels.go
│   │   ├── interfaces.go
│   │   ├── packages_imports.go
│   │   ├── README.md
│   │   ├── structs_methods.go
│   │   └── util
│   │       └── helpers.go
│   ├── sample_project_java
│   │   ├── out
│   │   │   └── com
│   │   │       └── example
│   │   │           └── app
│   │   │               ├── annotations
│   │   │               │   └── Logged.class
│   │   │               ├── Main.class
│   │   │               ├── misc
│   │   │               │   ├── Outer.class
│   │   │               │   └── Outer$Inner.class
│   │   │               ├── model
│   │   │               │   ├── Role.class
│   │   │               │   └── User.class
│   │   │               ├── service
│   │   │               │   ├── AbstractGreeter.class
│   │   │               │   ├── GreetingService.class
│   │   │               │   └── impl
│   │   │               │       └── GreetingServiceImpl.class
│   │   │               └── util
│   │   │                   ├── CollectionUtils.class
│   │   │                   └── IOHelper.class
│   │   ├── README.md
│   │   ├── sources.txt
│   │   └── src
│   │       └── com
│   │           └── example
│   │               └── app
│   │                   ├── annotations
│   │                   │   └── Logged.java
│   │                   ├── Main.java
│   │                   ├── misc
│   │                   │   └── Outer.java
│   │                   ├── model
│   │                   │   ├── Role.java
│   │                   │   └── User.java
│   │                   ├── service
│   │                   │   ├── AbstractGreeter.java
│   │                   │   ├── GreetingService.java
│   │                   │   └── impl
│   │                   │       └── GreetingServiceImpl.java
│   │                   └── util
│   │                       ├── CollectionUtils.java
│   │                       └── IOHelper.java
│   ├── sample_project_javascript
│   │   ├── arrays.js
│   │   ├── asyncAwait.js
│   │   ├── classes.js
│   │   ├── dom.js
│   │   ├── errorHandling.js
│   │   ├── events.js
│   │   ├── exporter.js
│   │   ├── fetchAPI.js
│   │   ├── fixtures
│   │   │   └── js
│   │   │       └── accessors.js
│   │   ├── functions.js
│   │   ├── importer.js
│   │   ├── objects.js
│   │   ├── promises.js
│   │   ├── README.md
│   │   └── variables.js
│   ├── sample_project_misc
│   │   ├── index.html
│   │   ├── README.md
│   │   ├── styles.css
│   │   ├── tables.css
│   │   └── tables.html
│   ├── sample_project_php
│   │   ├── classes_objects.php
│   │   ├── database.php
│   │   ├── edgecases.php
│   │   ├── error_handling.php
│   │   ├── file_handling.php
│   │   ├── functions.php
│   │   ├── generators_iterators.php
│   │   ├── globals_superglobals.php
│   │   ├── Inheritance.php
│   │   ├── interface_traits.php
│   │   └── README.md
│   ├── sample_project_ruby
│   │   ├── class_example.rb
│   │   ├── enumerables.rb
│   │   ├── error_handling.rb
│   │   ├── file_io.rb
│   │   ├── inheritance_example.rb
│   │   ├── main.rb
│   │   ├── metaprogramming.rb
│   │   ├── mixins_example.rb
│   │   ├── module_example.rb
│   │   └── tests
│   │       ├── test_mixins.py
│   │       └── test_sample.rb
│   ├── sample_project_rust
│   │   ├── Cargo.toml
│   │   ├── README.md
│   │   └── src
│   │       ├── basic_functions.rs
│   │       ├── concurrency.rs
│   │       ├── error_handling.rs
│   │       ├── generics.rs
│   │       ├── iterators_closures.rs
│   │       ├── lib.rs
│   │       ├── lifetimes_references.rs
│   │       ├── modules.rs
│   │       ├── smart_pointers.rs
│   │       ├── structs_enums.rs
│   │       └── traits.rs
│   ├── sample_project_typescript
│   │   ├── package.json
│   │   ├── README.md
│   │   ├── src
│   │   │   ├── advanced-types.ts
│   │   │   ├── async-promises.ts
│   │   │   ├── classes-inheritance.ts
│   │   │   ├── decorators-metadata.ts
│   │   │   ├── error-validation.ts
│   │   │   ├── functions-generics.ts
│   │   │   ├── index.ts
│   │   │   ├── modules-namespaces.ts
│   │   │   ├── types-interfaces.ts
│   │   │   └── utilities-helpers.ts
│   │   └── tsconfig.json
│   ├── test_cpp_parser.py
│   ├── test_database_validation.py
│   ├── test_end_to_end.py
│   ├── test_graph_indexing_js.py
│   ├── test_graph_indexing.py
│   ├── test_tree_sitter
│   │   ├── __init__.py
│   │   ├── class_instantiation.py
│   │   ├── complex_classes.py
│   │   └── test_file.py
│   └── test_typescript_parser.py
└── website
    ├── .example.env
    ├── .gitignore
    ├── api
    │   └── pypi.ts
    ├── bun.lockb
    ├── components.json
    ├── eslint.config.js
    ├── index.html
    ├── package-lock.json
    ├── package.json
    ├── postcss.config.js
    ├── public
    │   ├── favicon.ico
    │   ├── placeholder.svg
    │   └── robots.txt
    ├── README.md
    ├── src
    │   ├── App.css
    │   ├── App.tsx
    │   ├── assets
    │   │   ├── function-calls.png
    │   │   ├── graph-total.png
    │   │   ├── hero-graph.jpg
    │   │   └── hierarchy.png
    │   ├── components
    │   │   ├── ComparisonTable.tsx
    │   │   ├── CookbookSection.tsx
    │   │   ├── DemoSection.tsx
    │   │   ├── ExamplesSection.tsx
    │   │   ├── FeaturesSection.tsx
    │   │   ├── Footer.tsx
    │   │   ├── HeroSection.tsx
    │   │   ├── InstallationSection.tsx
    │   │   ├── MoveToTop.tsx
    │   │   ├── ShowDownloads.tsx
    │   │   ├── ShowStarGraph.tsx
    │   │   ├── TestimonialSection.tsx
    │   │   ├── ThemeProvider.tsx
    │   │   ├── ThemeToggle.tsx
    │   │   └── ui
    │   │       ├── accordion.tsx
    │   │       ├── alert-dialog.tsx
    │   │       ├── alert.tsx
    │   │       ├── aspect-ratio.tsx
    │   │       ├── avatar.tsx
    │   │       ├── badge.tsx
    │   │       ├── breadcrumb.tsx
    │   │       ├── button.tsx
    │   │       ├── calendar.tsx
    │   │       ├── card.tsx
    │   │       ├── carousel.tsx
    │   │       ├── chart.tsx
    │   │       ├── checkbox.tsx
    │   │       ├── collapsible.tsx
    │   │       ├── command.tsx
    │   │       ├── context-menu.tsx
    │   │       ├── dialog.tsx
    │   │       ├── drawer.tsx
    │   │       ├── dropdown-menu.tsx
    │   │       ├── form.tsx
    │   │       ├── hover-card.tsx
    │   │       ├── input-otp.tsx
    │   │       ├── input.tsx
    │   │       ├── label.tsx
    │   │       ├── menubar.tsx
    │   │       ├── navigation-menu.tsx
    │   │       ├── orbiting-circles.tsx
    │   │       ├── pagination.tsx
    │   │       ├── popover.tsx
    │   │       ├── progress.tsx
    │   │       ├── radio-group.tsx
    │   │       ├── resizable.tsx
    │   │       ├── scroll-area.tsx
    │   │       ├── select.tsx
    │   │       ├── separator.tsx
    │   │       ├── sheet.tsx
    │   │       ├── sidebar.tsx
    │   │       ├── skeleton.tsx
    │   │       ├── slider.tsx
    │   │       ├── sonner.tsx
    │   │       ├── switch.tsx
    │   │       ├── table.tsx
    │   │       ├── tabs.tsx
    │   │       ├── textarea.tsx
    │   │       ├── toast.tsx
    │   │       ├── toaster.tsx
    │   │       ├── toggle-group.tsx
    │   │       ├── toggle.tsx
    │   │       ├── tooltip.tsx
    │   │       └── use-toast.ts
    │   ├── hooks
    │   │   ├── use-mobile.tsx
    │   │   └── use-toast.ts
    │   ├── index.css
    │   ├── lib
    │   │   └── utils.ts
    │   ├── main.tsx
    │   ├── pages
    │   │   ├── Index.tsx
    │   │   └── NotFound.tsx
    │   └── vite-env.d.ts
    ├── tailwind.config.ts
    ├── tsconfig.app.json
    ├── tsconfig.json
    ├── tsconfig.node.json
    ├── vercel.json
    └── vite.config.ts
```

# Files

--------------------------------------------------------------------------------
/docs/site/cookbook/index.html:
--------------------------------------------------------------------------------

```html

<!doctype html>
<html lang="en" class="no-js">
  <head>
    
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1">
      
      
      
      
        <link rel="prev" href="../tools/">
      
      
        <link rel="next" href="../contributing/">
      
      
      <link rel="icon" href="../assets/images/favicon.png">
      <meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.6.21">
    
    
      
        <title>Cookbook - CodeGraphContext</title>
      
    
    
      <link rel="stylesheet" href="../assets/stylesheets/main.2a3383ac.min.css">
      
      


    
    
      
    
    
      
        
        
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
        <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
      
    
    
    <script>__md_scope=new URL("..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
    
      

    
    
    
  </head>
  
  
    <body dir="ltr">
  
    
    <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
    <label class="md-overlay" for="__drawer"></label>
    <div data-md-component="skip">
      
        
        <a href="#mcp-tool-cookbook" class="md-skip">
          Skip to content
        </a>
      
    </div>
    <div data-md-component="announce">
      
    </div>
    
    
      

  

<header class="md-header md-header--shadow" data-md-component="header">
  <nav class="md-header__inner md-grid" aria-label="Header">
    <a href=".." title="CodeGraphContext" class="md-header__button md-logo" aria-label="CodeGraphContext" data-md-component="logo">
      
  
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg>

    </a>
    <label class="md-header__button md-icon" for="__drawer">
      
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
    </label>
    <div class="md-header__title" data-md-component="header-title">
      <div class="md-header__ellipsis">
        <div class="md-header__topic">
          <span class="md-ellipsis">
            CodeGraphContext
          </span>
        </div>
        <div class="md-header__topic" data-md-component="header-topic">
          <span class="md-ellipsis">
            
              Cookbook
            
          </span>
        </div>
      </div>
    </div>
    
    
      <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
    
    
    
      
      
        <label class="md-header__button md-icon" for="__search">
          
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
        </label>
        <div class="md-search" data-md-component="search" role="dialog">
  <label class="md-search__overlay" for="__search"></label>
  <div class="md-search__inner" role="search">
    <form class="md-search__form" name="search">
      <input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
      <label class="md-search__icon md-icon" for="__search">
        
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
        
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
      </label>
      <nav class="md-search__options" aria-label="Search">
        
        <button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
          
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
        </button>
      </nav>
      
    </form>
    <div class="md-search__output">
      <div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
        <div class="md-search-result" data-md-component="search-result">
          <div class="md-search-result__meta">
            Initializing search
          </div>
          <ol class="md-search-result__list" role="presentation"></ol>
        </div>
      </div>
    </div>
  </div>
</div>
      
    
    
  </nav>
  
</header>
    
    <div class="md-container" data-md-component="container">
      
      
        
          
        
      
      <main class="md-main" data-md-component="main">
        <div class="md-main__inner md-grid">
          
            
              
              <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    



<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
  <label class="md-nav__title" for="__drawer">
    <a href=".." title="CodeGraphContext" class="md-nav__button md-logo" aria-label="CodeGraphContext" data-md-component="logo">
      
  
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 0 0 3-3 3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54"/></svg>

    </a>
    CodeGraphContext
  </label>
  
  <ul class="md-nav__list" data-md-scrollfix>
    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href=".." class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Home
    
  </span>
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../installation/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Installation
    
  </span>
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../use_cases/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Use Cases
    
  </span>
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../architecture/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Architecture
    
  </span>
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../cli/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    CLI Reference
    
  </span>
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../server/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Server
    
  </span>
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../core/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Core Concepts
    
  </span>
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../tools/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Tools
    
  </span>
  

      </a>
    </li>
  

    
      
      
  
  
    
  
  
  
    <li class="md-nav__item md-nav__item--active">
      
      <input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
      
      
        
      
      
        <label class="md-nav__link md-nav__link--active" for="__toc">
          
  
  
  <span class="md-ellipsis">
    Cookbook
    
  </span>
  

          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <a href="./" class="md-nav__link md-nav__link--active">
        
  
  
  <span class="md-ellipsis">
    Cookbook
    
  </span>
  

      </a>
      
        

<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      Table of contents
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#basic-queries" class="md-nav__link">
    <span class="md-ellipsis">
      Basic Queries
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Basic Queries">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#1-find-a-specific-function-by-name" class="md-nav__link">
    <span class="md-ellipsis">
      1. Find a specific function by name
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#2-find-all-calls-to-a-specific-function" class="md-nav__link">
    <span class="md-ellipsis">
      2. Find all calls to a specific function
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#3-find-what-a-function-calls" class="md-nav__link">
    <span class="md-ellipsis">
      3. Find what a function calls
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#4-find-all-imports-of-a-specific-module" class="md-nav__link">
    <span class="md-ellipsis">
      4. Find all imports of a specific module
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#5-find-all-methods-of-a-class" class="md-nav__link">
    <span class="md-ellipsis">
      5. Find all methods of a class
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#6-find-all-classes-that-inherit-from-a-specific-class" class="md-nav__link">
    <span class="md-ellipsis">
      6. Find all classes that inherit from a specific class
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#7-find-all-functions-with-a-specific-decorator" class="md-nav__link">
    <span class="md-ellipsis">
      7. Find all functions with a specific decorator
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#8-find-all-dataclasses" class="md-nav__link">
    <span class="md-ellipsis">
      8. Find all dataclasses
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#code-analysis-quality" class="md-nav__link">
    <span class="md-ellipsis">
      Code Analysis &amp; Quality
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Code Analysis &amp; Quality">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#9-find-the-5-most-complex-functions" class="md-nav__link">
    <span class="md-ellipsis">
      9. Find the 5 most complex functions
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#10-calculate-cyclomatic-complexity-of-a-function" class="md-nav__link">
    <span class="md-ellipsis">
      10. Calculate cyclomatic complexity of a function
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#11-find-unused-code" class="md-nav__link">
    <span class="md-ellipsis">
      11. Find unused code
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#12-find-the-call-chain-between-two-functions" class="md-nav__link">
    <span class="md-ellipsis">
      12. Find the call chain between two functions
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#13-find-all-direct-and-indirect-callers-of-a-function" class="md-nav__link">
    <span class="md-ellipsis">
      13. Find all direct and indirect callers of a function
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#14-find-functions-by-argument-name" class="md-nav__link">
    <span class="md-ellipsis">
      14. Find functions by argument name
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#15-list-all-python-package-imports-from-a-directory" class="md-nav__link">
    <span class="md-ellipsis">
      15. List all python package imports from a directory
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#repository-information-queries" class="md-nav__link">
    <span class="md-ellipsis">
      Repository Information Queries
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Repository Information Queries">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#16-list-all-indexed-projects" class="md-nav__link">
    <span class="md-ellipsis">
      16. List all indexed projects
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#17-check-the-status-of-an-indexing-job" class="md-nav__link">
    <span class="md-ellipsis">
      17. Check the status of an indexing job
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#18-list-all-background-jobs" class="md-nav__link">
    <span class="md-ellipsis">
      18. List all background jobs
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#advanced-cypher-queries" class="md-nav__link">
    <span class="md-ellipsis">
      Advanced Cypher Queries
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Advanced Cypher Queries">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#19-find-all-function-definitions" class="md-nav__link">
    <span class="md-ellipsis">
      19. Find all function definitions
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#20-find-all-classes" class="md-nav__link">
    <span class="md-ellipsis">
      20. Find all classes
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#21-find-all-functions-in-a-file" class="md-nav__link">
    <span class="md-ellipsis">
      21. Find all functions in a file
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#22-find-all-classes-in-a-file" class="md-nav__link">
    <span class="md-ellipsis">
      22. Find all classes in a file
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#23-list-all-top-level-functions-and-classes-in-a-file" class="md-nav__link">
    <span class="md-ellipsis">
      23. List all top-level functions and classes in a file
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#24-find-functions-in-one-module-that-call-a-function-in-another" class="md-nav__link">
    <span class="md-ellipsis">
      24. Find functions in one module that call a function in another
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#25-find-circular-file-imports" class="md-nav__link">
    <span class="md-ellipsis">
      25. Find circular file imports
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#26-find-all-functions-with-more-than-5-arguments" class="md-nav__link">
    <span class="md-ellipsis">
      26. Find all functions with more than 5 arguments
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#27-find-all-functions-in-a-file-that-have-a-docstring" class="md-nav__link">
    <span class="md-ellipsis">
      27. Find all functions in a file that have a docstring
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#28-find-all-classes-that-have-a-specific-method" class="md-nav__link">
    <span class="md-ellipsis">
      28. Find all classes that have a specific method
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#29-find-the-depth-of-inheritance-for-all-classes" class="md-nav__link">
    <span class="md-ellipsis">
      29. Find the depth of inheritance for all classes
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#30-find-all-functions-that-have-a-docstring" class="md-nav__link">
    <span class="md-ellipsis">
      30. Find all functions that have a docstring
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#31-find-all-decorated-methods-in-a-class" class="md-nav__link">
    <span class="md-ellipsis">
      31. Find all decorated methods in a class
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#32-find-the-number-of-functions-in-each-file" class="md-nav__link">
    <span class="md-ellipsis">
      32. Find the number of functions in each file
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#33-find-all-methods-that-override-a-parent-method" class="md-nav__link">
    <span class="md-ellipsis">
      33. Find all methods that override a parent method
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#34-find-all-functions-that-call-super" class="md-nav__link">
    <span class="md-ellipsis">
      34. Find all functions that call super()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#35-find-all-calls-to-a-function-with-a-specific-argument" class="md-nav__link">
    <span class="md-ellipsis">
      35. Find all calls to a function with a specific argument
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#36-find-all-functions-that-are-not-called-by-any-other-function" class="md-nav__link">
    <span class="md-ellipsis">
      36. Find all functions that are not called by any other function
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#37-find-all-functions-that-are-called-with-a-specific-argument" class="md-nav__link">
    <span class="md-ellipsis">
      37. Find all functions that are called with a specific argument
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#38-find-all-direct-and-indirect-callees-of-a-function" class="md-nav__link">
    <span class="md-ellipsis">
      38. Find all direct and indirect callees of a function
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#39-find-all-functions-that-are-overridden" class="md-nav__link">
    <span class="md-ellipsis">
      39. Find all functions that are overridden
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#40-find-all-modules-imported-by-module_a" class="md-nav__link">
    <span class="md-ellipsis">
      40. Find all modules imported by module_a
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#41-find-large-functions-that-should-be-refactored" class="md-nav__link">
    <span class="md-ellipsis">
      41. Find large functions that should be refactored
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#42-find-recursive-functions" class="md-nav__link">
    <span class="md-ellipsis">
      42. Find recursive functions
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#43-find-most-connected-functions-hub-functions" class="md-nav__link">
    <span class="md-ellipsis">
      43. Find most connected functions (hub functions)
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#security-sensitive-data-analysis" class="md-nav__link">
    <span class="md-ellipsis">
      Security &amp; Sensitive Data Analysis
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Security &amp; Sensitive Data Analysis">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#44-find-potential-security-vulnerabilities-hardcoded-secrets" class="md-nav__link">
    <span class="md-ellipsis">
      44. Find potential security vulnerabilities (hardcoded secrets)
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
    </ul>
  
</nav>
      
    </li>
  

    
      
      
  
  
  
  
    
    
    
    
    
    <li class="md-nav__item md-nav__item--nested">
      
        
        
        <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_10" >
        
          
          <label class="md-nav__link" for="__nav_10" id="__nav_10_label" tabindex="0">
            
  
  
  <span class="md-ellipsis">
    Contributing
    
  </span>
  

            <span class="md-nav__icon md-icon"></span>
          </label>
        
        <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_10_label" aria-expanded="false">
          <label class="md-nav__title" for="__nav_10">
            <span class="md-nav__icon md-icon"></span>
            Contributing
          </label>
          <ul class="md-nav__list" data-md-scrollfix>
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../contributing/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Overview
    
  </span>
  

      </a>
    </li>
  

              
            
              
                
  
  
  
  
    <li class="md-nav__item">
      <a href="../contributing_languages/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Adding New Languages
    
  </span>
  

      </a>
    </li>
  

              
            
          </ul>
        </nav>
      
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../troubleshooting/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Troubleshooting
    
  </span>
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../future_work/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    Future Work
    
  </span>
  

      </a>
    </li>
  

    
      
      
  
  
  
  
    <li class="md-nav__item">
      <a href="../license/" class="md-nav__link">
        
  
  
  <span class="md-ellipsis">
    License
    
  </span>
  

      </a>
    </li>
  

    
  </ul>
</nav>
                  </div>
                </div>
              </div>
            
            
              
              <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      Table of contents
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#basic-queries" class="md-nav__link">
    <span class="md-ellipsis">
      Basic Queries
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Basic Queries">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#1-find-a-specific-function-by-name" class="md-nav__link">
    <span class="md-ellipsis">
      1. Find a specific function by name
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#2-find-all-calls-to-a-specific-function" class="md-nav__link">
    <span class="md-ellipsis">
      2. Find all calls to a specific function
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#3-find-what-a-function-calls" class="md-nav__link">
    <span class="md-ellipsis">
      3. Find what a function calls
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#4-find-all-imports-of-a-specific-module" class="md-nav__link">
    <span class="md-ellipsis">
      4. Find all imports of a specific module
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#5-find-all-methods-of-a-class" class="md-nav__link">
    <span class="md-ellipsis">
      5. Find all methods of a class
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#6-find-all-classes-that-inherit-from-a-specific-class" class="md-nav__link">
    <span class="md-ellipsis">
      6. Find all classes that inherit from a specific class
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#7-find-all-functions-with-a-specific-decorator" class="md-nav__link">
    <span class="md-ellipsis">
      7. Find all functions with a specific decorator
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#8-find-all-dataclasses" class="md-nav__link">
    <span class="md-ellipsis">
      8. Find all dataclasses
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#code-analysis-quality" class="md-nav__link">
    <span class="md-ellipsis">
      Code Analysis &amp; Quality
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Code Analysis &amp; Quality">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#9-find-the-5-most-complex-functions" class="md-nav__link">
    <span class="md-ellipsis">
      9. Find the 5 most complex functions
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#10-calculate-cyclomatic-complexity-of-a-function" class="md-nav__link">
    <span class="md-ellipsis">
      10. Calculate cyclomatic complexity of a function
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#11-find-unused-code" class="md-nav__link">
    <span class="md-ellipsis">
      11. Find unused code
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#12-find-the-call-chain-between-two-functions" class="md-nav__link">
    <span class="md-ellipsis">
      12. Find the call chain between two functions
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#13-find-all-direct-and-indirect-callers-of-a-function" class="md-nav__link">
    <span class="md-ellipsis">
      13. Find all direct and indirect callers of a function
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#14-find-functions-by-argument-name" class="md-nav__link">
    <span class="md-ellipsis">
      14. Find functions by argument name
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#15-list-all-python-package-imports-from-a-directory" class="md-nav__link">
    <span class="md-ellipsis">
      15. List all python package imports from a directory
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#repository-information-queries" class="md-nav__link">
    <span class="md-ellipsis">
      Repository Information Queries
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Repository Information Queries">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#16-list-all-indexed-projects" class="md-nav__link">
    <span class="md-ellipsis">
      16. List all indexed projects
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#17-check-the-status-of-an-indexing-job" class="md-nav__link">
    <span class="md-ellipsis">
      17. Check the status of an indexing job
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#18-list-all-background-jobs" class="md-nav__link">
    <span class="md-ellipsis">
      18. List all background jobs
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#advanced-cypher-queries" class="md-nav__link">
    <span class="md-ellipsis">
      Advanced Cypher Queries
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Advanced Cypher Queries">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#19-find-all-function-definitions" class="md-nav__link">
    <span class="md-ellipsis">
      19. Find all function definitions
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#20-find-all-classes" class="md-nav__link">
    <span class="md-ellipsis">
      20. Find all classes
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#21-find-all-functions-in-a-file" class="md-nav__link">
    <span class="md-ellipsis">
      21. Find all functions in a file
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#22-find-all-classes-in-a-file" class="md-nav__link">
    <span class="md-ellipsis">
      22. Find all classes in a file
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#23-list-all-top-level-functions-and-classes-in-a-file" class="md-nav__link">
    <span class="md-ellipsis">
      23. List all top-level functions and classes in a file
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#24-find-functions-in-one-module-that-call-a-function-in-another" class="md-nav__link">
    <span class="md-ellipsis">
      24. Find functions in one module that call a function in another
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#25-find-circular-file-imports" class="md-nav__link">
    <span class="md-ellipsis">
      25. Find circular file imports
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#26-find-all-functions-with-more-than-5-arguments" class="md-nav__link">
    <span class="md-ellipsis">
      26. Find all functions with more than 5 arguments
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#27-find-all-functions-in-a-file-that-have-a-docstring" class="md-nav__link">
    <span class="md-ellipsis">
      27. Find all functions in a file that have a docstring
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#28-find-all-classes-that-have-a-specific-method" class="md-nav__link">
    <span class="md-ellipsis">
      28. Find all classes that have a specific method
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#29-find-the-depth-of-inheritance-for-all-classes" class="md-nav__link">
    <span class="md-ellipsis">
      29. Find the depth of inheritance for all classes
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#30-find-all-functions-that-have-a-docstring" class="md-nav__link">
    <span class="md-ellipsis">
      30. Find all functions that have a docstring
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#31-find-all-decorated-methods-in-a-class" class="md-nav__link">
    <span class="md-ellipsis">
      31. Find all decorated methods in a class
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#32-find-the-number-of-functions-in-each-file" class="md-nav__link">
    <span class="md-ellipsis">
      32. Find the number of functions in each file
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#33-find-all-methods-that-override-a-parent-method" class="md-nav__link">
    <span class="md-ellipsis">
      33. Find all methods that override a parent method
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#34-find-all-functions-that-call-super" class="md-nav__link">
    <span class="md-ellipsis">
      34. Find all functions that call super()
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#35-find-all-calls-to-a-function-with-a-specific-argument" class="md-nav__link">
    <span class="md-ellipsis">
      35. Find all calls to a function with a specific argument
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#36-find-all-functions-that-are-not-called-by-any-other-function" class="md-nav__link">
    <span class="md-ellipsis">
      36. Find all functions that are not called by any other function
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#37-find-all-functions-that-are-called-with-a-specific-argument" class="md-nav__link">
    <span class="md-ellipsis">
      37. Find all functions that are called with a specific argument
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#38-find-all-direct-and-indirect-callees-of-a-function" class="md-nav__link">
    <span class="md-ellipsis">
      38. Find all direct and indirect callees of a function
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#39-find-all-functions-that-are-overridden" class="md-nav__link">
    <span class="md-ellipsis">
      39. Find all functions that are overridden
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#40-find-all-modules-imported-by-module_a" class="md-nav__link">
    <span class="md-ellipsis">
      40. Find all modules imported by module_a
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#41-find-large-functions-that-should-be-refactored" class="md-nav__link">
    <span class="md-ellipsis">
      41. Find large functions that should be refactored
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#42-find-recursive-functions" class="md-nav__link">
    <span class="md-ellipsis">
      42. Find recursive functions
    </span>
  </a>
  
</li>
        
          <li class="md-nav__item">
  <a href="#43-find-most-connected-functions-hub-functions" class="md-nav__link">
    <span class="md-ellipsis">
      43. Find most connected functions (hub functions)
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
        <li class="md-nav__item">
  <a href="#security-sensitive-data-analysis" class="md-nav__link">
    <span class="md-ellipsis">
      Security &amp; Sensitive Data Analysis
    </span>
  </a>
  
    <nav class="md-nav" aria-label="Security &amp; Sensitive Data Analysis">
      <ul class="md-nav__list">
        
          <li class="md-nav__item">
  <a href="#44-find-potential-security-vulnerabilities-hardcoded-secrets" class="md-nav__link">
    <span class="md-ellipsis">
      44. Find potential security vulnerabilities (hardcoded secrets)
    </span>
  </a>
  
</li>
        
      </ul>
    </nav>
  
</li>
      
    </ul>
  
</nav>
                  </div>
                </div>
              </div>
            
          
          
            <div class="md-content" data-md-component="content">
              <article class="md-content__inner md-typeset">
                
                  



<h1 id="mcp-tool-cookbook">MCP Tool Cookbook</h1>
<p>This cookbook provides examples of how to use the <code>mcp</code> tool to query and understand your Python codebase. The "Tool" indicates which <code>mcp</code> tool to use, and the "JSON Arguments" are what the LLM would provide to that tool.</p>
<hr />
<h2 id="basic-queries">Basic Queries</h2>
<h3 id="1-find-a-specific-function-by-name">1. Find a specific function by name</h3>
<ul>
<li><strong>Natural Language:</strong> "Where is the function <code>foo</code> defined?"</li>
<li><strong>Tool:</strong> <code>find_code</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query&quot;: &quot;foo&quot;
}
</code></pre>
<p><img alt="Query 1" src="../images/1.png" /></p>
<h3 id="2-find-all-calls-to-a-specific-function">2. Find all calls to a specific function</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all calls to the <code>helper</code> function."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_callers&quot;,
  &quot;target&quot;: &quot;helper&quot;
}
</code></pre>
<p><img alt="Query 2" src="../images/2.png" /></p>
<h3 id="3-find-what-a-function-calls">3. Find what a function calls</h3>
<ul>
<li><strong>Natural Language:</strong> "What functions are called inside the <code>foo</code> function?"</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_callees&quot;,
  &quot;target&quot;: &quot;foo&quot;,
  &quot;context&quot;: &quot;/teamspace/studios/this_studio/demo/CodeGraphContext/tests/sample_project/module_a.py&quot;
}
</code></pre>
<p><img alt="Query 3" src="../images/3.png" /></p>
<h3 id="4-find-all-imports-of-a-specific-module">4. Find all imports of a specific module</h3>
<ul>
<li><strong>Natural Language:</strong> "Where is the <code>math</code> module imported?"</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_importers&quot;,
  &quot;target&quot;: &quot;math&quot;
}
</code></pre>
<p><img alt="Query 4" src="../images/4.png" /></p>
<h3 id="5-find-all-methods-of-a-class">5. Find all methods of a class</h3>
<ul>
<li><strong>Natural Language:</strong> "What are the methods of the <code>A</code> class?"</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;class_hierarchy&quot;,
  &quot;target&quot;: &quot;A&quot;
}
</code></pre>
<ul>
<li><strong>Note:</strong> The response for <code>class_hierarchy</code> includes a list of methods.</li>
</ul>
<p><img alt="Query 5" src="../images/5.png" /></p>
<h3 id="6-find-all-classes-that-inherit-from-a-specific-class">6. Find all classes that inherit from a specific class</h3>
<ul>
<li><strong>Natural Language:</strong> "Show me all classes that inherit from <code>Base</code>."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;class_hierarchy&quot;,
  &quot;target&quot;: &quot;Base&quot;
}
</code></pre>
<ul>
<li><strong>Note:</strong> The response for <code>class_hierarchy</code> includes a list of child classes.</li>
</ul>
<p><img alt="Query 6" src="../images/6.png" /></p>
<h3 id="7-find-all-functions-with-a-specific-decorator">7. Find all functions with a specific decorator</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions with the <code>log_decorator</code>."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_functions_by_decorator&quot;,
  &quot;target&quot;: &quot;log_decorator&quot;
}
</code></pre>
<p><img alt="Query 7" src="../images/7.png" /></p>
<h3 id="8-find-all-dataclasses">8. Find all dataclasses</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all dataclasses."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (c:Class) WHERE 'dataclass' IN c.decorators RETURN c.name, c.file_path&quot;
}
</code></pre>
<p><img alt="Query 8" src="../images/8.png" /></p>
<hr />
<h2 id="code-analysis-quality">Code Analysis &amp; Quality</h2>
<h3 id="9-find-the-5-most-complex-functions">9. Find the 5 most complex functions</h3>
<ul>
<li><strong>Natural Language:</strong> "Find the 5 most complex functions."</li>
<li><strong>Tool:</strong> <code>find_most_complex_functions</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;limit&quot;: 5
}
</code></pre>
<p><img alt="Query 9" src="../images/9.png" /></p>
<h3 id="10-calculate-cyclomatic-complexity-of-a-function">10. Calculate cyclomatic complexity of a function</h3>
<ul>
<li><strong>Natural Language:</strong> "What is the cyclomatic complexity of <code>try_except_finally</code>?"</li>
<li><strong>Tool:</strong> <code>calculate_cyclomatic_complexity</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;function_name&quot;: &quot;try_except_finally&quot;
}
</code></pre>
<h3 id="11-find-unused-code">11. Find unused code</h3>
<ul>
<li><strong>Natural Language:</strong> "Find unused code, but ignore API endpoints decorated with <code>@app.route</code>."</li>
<li><strong>Tool:</strong> <code>find_dead_code</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;exclude_decorated_with&quot;: [&quot;@app.route&quot;]
}
</code></pre>
<p><img alt="Query 11" src="../images/11.png" /></p>
<h3 id="12-find-the-call-chain-between-two-functions">12. Find the call chain between two functions</h3>
<ul>
<li><strong>Natural Language:</strong> "What is the call chain from <code>wrapper</code> to <code>helper</code>?"</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;call_chain&quot;,
  &quot;target&quot;: &quot;wrapper-&gt;helper&quot;
}
</code></pre>
<p><img alt="Query 12" src="../images/12.png" /></p>
<h3 id="13-find-all-direct-and-indirect-callers-of-a-function">13. Find all direct and indirect callers of a function</h3>
<ul>
<li><strong>Natural Language:</strong> "Show me all functions that eventually call the <code>helper</code> function."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_all_callers&quot;,
  &quot;target&quot;: &quot;helper&quot;
}
</code></pre>
<p><img alt="Query 13" src="../images/13.png" /></p>
<h3 id="14-find-functions-by-argument-name">14. Find functions by argument name</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions that take <code>self</code> as an argument."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_functions_by_argument&quot;,
  &quot;target&quot;: &quot;self&quot;
}
</code></pre>
<p><img alt="Query 14" src="../images/14.png" /></p>
<h3 id="15-list-all-python-package-imports-from-a-directory">15. List all python package imports from a directory</h3>
<ul>
<li><strong>Natural Language:</strong> "List all python package imports from my project directory."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:File)-[:IMPORTS]-&gt;(m:Module) WHERE f.path ENDS WITH '.py' RETURN DISTINCT m.name&quot;
}
</code></pre>
<hr />
<h2 id="repository-information-queries">Repository Information Queries</h2>
<h3 id="16-list-all-indexed-projects">16. List all indexed projects</h3>
<ul>
<li><strong>Natural Language:</strong> "List all projects I have indexed."</li>
<li><strong>Tool:</strong> <code>list_indexed_repositories</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">  {}
</code></pre>
<p><img alt="Query 16" src="../images/16.png" /></p>
<h3 id="17-check-the-status-of-an-indexing-job">17. Check the status of an indexing job</h3>
<ul>
<li><strong>Natural Language:</strong> "What is the status of job <code>4cb9a60e-c1b1-43a7-9c94-c840771506bc</code>?"</li>
<li><strong>Tool:</strong> <code>check_job_status</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;job_id&quot;: &quot;4cb9a60e-c1b1-43a7-9c94-c840771506bc&quot;
}
</code></pre>
<h3 id="18-list-all-background-jobs">18. List all background jobs</h3>
<ul>
<li><strong>Natural Language:</strong> "Show me all background jobs."</li>
<li><strong>Tool:</strong> <code>list_jobs</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">  {}
</code></pre>
<hr />
<h2 id="advanced-cypher-queries">Advanced Cypher Queries</h2>
<p>These examples use the <code>execute_cypher_query</code> tool for more specific and complex questions.</p>
<h3 id="19-find-all-function-definitions">19. Find all function definitions</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all function definitions in the codebase."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (n:Function) RETURN n.name, n.file_path, n.line_number LIMIT 50&quot;
}
</code></pre>
<p><img alt="Query 19" src="../images/19.png" /></p>
<h3 id="20-find-all-classes">20. Find all classes</h3>
<ul>
<li><strong>Natural Language:</strong> "Show me all the classes."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (n:Class) RETURN n.name, n.file_path, n.line_number LIMIT 50&quot;
}
</code></pre>
<p><img alt="Query 20" src="../images/20.png" /></p>
<h3 id="21-find-all-functions-in-a-file">21. Find all functions in a file</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions in <code>module_a.py</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function) WHERE f.file_path ENDS WITH 'module_a.py' RETURN f.name&quot;
}
</code></pre>
<p><img alt="Query 21" src="../images/21.png" /></p>
<h3 id="22-find-all-classes-in-a-file">22. Find all classes in a file</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all classes in <code>advanced_classes.py</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (c:Class) WHERE c.file_path ENDS WITH 'advanced_classes.py' RETURN c.name&quot;
}
</code></pre>
<p><img alt="Query 22" src="../images/22.png" /></p>
<h3 id="23-list-all-top-level-functions-and-classes-in-a-file">23. List all top-level functions and classes in a file</h3>
<ul>
<li><strong>Natural Language:</strong> "List all top-level functions and classes in <code>module_a.py</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:File)-[:CONTAINS]-&gt;(n) WHERE f.name = 'module_a.py' AND (n:Function OR n:Class) AND n.context IS NULL RETURN n.name&quot;
}
</code></pre>
<p><img alt="Query 23" src="../images/23.png" /></p>
<h3 id="24-find-functions-in-one-module-that-call-a-function-in-another">24. Find functions in one module that call a function in another</h3>
<ul>
<li><strong>Natural Language:</strong> "Find functions in <code>module_a.py</code> that call <code>helper</code> in <code>module_b.py</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (caller:Function)-[:CALLS]-&gt;(callee:Function {name: 'helper'}) WHERE caller.file_path ENDS WITH 'module_a.py' AND callee.file_path ENDS WITH 'module_b.py' RETURN caller.name&quot;
}
</code></pre>
<p><img alt="Query 24" src="../images/24.png" /></p>
<h3 id="25-find-circular-file-imports">25. Find circular file imports</h3>
<ul>
<li><strong>Natural Language:</strong> "Are there any circular dependencies between files?"</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f1:File)-[:IMPORTS]-&gt;(m2:Module), (f2:File)-[:IMPORTS]-&gt;(m1:Module) WHERE f1.name = m1.name + '.py' AND f2.name = m2.name + '.py' RETURN f1.name, f2.name&quot;
}
</code></pre>
<h3 id="26-find-all-functions-with-more-than-5-arguments">26. Find all functions with more than 5 arguments</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions with a large number of arguments."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function) WHERE size(f.args) &gt; 5 RETURN f.name, f.file_path, size(f.args) as arg_count&quot;
}
</code></pre>
<p><img alt="Query 26" src="../images/26.png" /></p>
<h3 id="27-find-all-functions-in-a-file-that-have-a-docstring">27. Find all functions in a file that have a docstring</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions in <code>module_a.py</code> that have a docstring."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function) WHERE f.file_path ENDS WITH 'module_a.py' AND f.docstring IS NOT NULL AND f.docstring &lt;&gt; '' RETURN f.name&quot;
}
</code></pre>
<h3 id="28-find-all-classes-that-have-a-specific-method">28. Find all classes that have a specific method</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all classes that have a <code>greet</code> method."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (c:Class)-[:CONTAINS]-&gt;(m:Function {name: 'greet'}) RETURN c.name, c.file_path&quot;
}
</code></pre>
<p><img alt="Query 28" src="../images/28.png" /></p>
<h3 id="29-find-the-depth-of-inheritance-for-all-classes">29. Find the depth of inheritance for all classes</h3>
<ul>
<li><strong>Natural Language:</strong> "How deep are the inheritance chains for all classes?"</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (c:Class) OPTIONAL MATCH path = (c)-[:INHERITS*]-&gt;(parent:Class) RETURN c.name, c.file_path, length(path) AS depth ORDER BY depth DESC&quot;
}
</code></pre>
<p><img alt="Query 29" src="../images/29.png" /></p>
<h3 id="30-find-all-functions-that-have-a-docstring">30. Find all functions that have a docstring</h3>
<ul>
<li><strong>Natural Language:</strong> "Show me all functions that are documented."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function) WHERE f.docstring IS NOT NULL AND f.docstring &lt;&gt; '' RETURN f.name, f.file_path LIMIT 50&quot;
}
</code></pre>
<p><img alt="Query 30" src="../images/30.png" /></p>
<h3 id="31-find-all-decorated-methods-in-a-class">31. Find all decorated methods in a class</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all decorated methods in the <code>Child</code> class."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (c:Class {name: 'Child'})-[:CONTAINS]-&gt;(m:Function) WHERE m.decorators IS NOT NULL AND size(m.decorators) &gt; 0 RETURN m.name&quot;
}
</code></pre>
<p><img alt="Query 31" src="../images/31.png" /></p>
<h3 id="32-find-the-number-of-functions-in-each-file">32. Find the number of functions in each file</h3>
<ul>
<li><strong>Natural Language:</strong> "How many functions are in each file?"</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function) RETURN f.file_path, count(f) AS function_count ORDER BY function_count DESC&quot;
}
</code></pre>
<p><img alt="Query 32" src="../images/32.png" /></p>
<h3 id="33-find-all-methods-that-override-a-parent-method">33. Find all methods that override a parent method</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all methods that are overridden from a parent class."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (c:Class)-[:INHERITS]-&gt;(p:Class), (c)-[:CONTAINS]-&gt;(m:Function), (p)-[:CONTAINS]-&gt;(m_parent:Function) WHERE m.name = m_parent.name RETURN m.name as method, c.name as child_class, p.name as parent_class&quot;
}
</code></pre>
<p><img alt="Query 33" src="../images/33.png" /></p>
<h3 id="34-find-all-functions-that-call-super">34. Find all functions that call <code>super()</code></h3>
<ul>
<li><strong>Natural Language:</strong> "Find all methods that call their parent's method via <code>super()</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function)-[r:CALLS]-&gt;() WHERE r.full_call_name STARTS WITH 'super(' RETURN f.name, f.file_path&quot;
}
</code></pre>
<p><img alt="Query 34" src="../images/34.png" /></p>
<h3 id="35-find-all-calls-to-a-function-with-a-specific-argument">35. Find all calls to a function with a specific argument</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all calls to <code>helper</code> with the argument <code>x</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH ()-[r:CALLS]-&gt;(f:Function {name: 'helper'}) WHERE 'x' IN r.args RETURN r.full_call_name, r.line_number, r.file_path&quot;
}
</code></pre>
<p><img alt="Query 35" src="../images/35.png" /></p>
<h3 id="36-find-all-functions-that-are-not-called-by-any-other-function">36. Find all functions that are not called by any other function</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all dead code (functions that are never called)."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function) WHERE NOT (()-[:CALLS]-&gt;(f)) AND f.is_dependency = false RETURN f.name, f.file_path&quot;
}
</code></pre>
<p><img alt="Query 36" src="../images/36.png" /></p>
<h3 id="37-find-all-functions-that-are-called-with-a-specific-argument">37. Find all functions that are called with a specific argument</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all calls to <code>print</code> with the argument <code>'hello'</code>."</li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (c:Call) WHERE c.name = 'print' AND 'hello' IN c.args RETURN c.file, c.lineno&quot;
}
</code></pre>
<h3 id="38-find-all-direct-and-indirect-callees-of-a-function">38. Find all direct and indirect callees of a function</h3>
<ul>
<li><strong>Natural Language:</strong> "Show me all functions that are eventually called by the <code>foo</code> function."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;find_all_callees&quot;,
  &quot;target&quot;: &quot;foo&quot;,
  &quot;context&quot;: &quot;/teamspace/studios/this_studio/demo/CodeGraphContext/tests/sample_project/module_a.py&quot;
}
</code></pre>
<p><img alt="Query 38" src="../images/38.png" /></p>
<h3 id="39-find-all-functions-that-are-overridden">39. Find all functions that are overridden</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions that are overridden."</li>
<li><strong>Tool:</strong> <code>analyze_code_relationships</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;query_type&quot;: &quot;overrides&quot;,
  &quot;target&quot;: &quot;foo&quot;
}
</code></pre>
<p><img alt="Query 39" src="../images/39.png" /></p>
<h3 id="40-find-all-modules-imported-by-module_a">40. Find all modules imported by <code>module_a</code></h3>
<ul>
<li><strong>Natural Language:</strong> "Find all modules imported by <code>module_a</code>."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:File {name: 'module_a.py'})-[:IMPORTS]-&gt;(m:Module) RETURN m.name AS imported_module_name&quot;
}
</code></pre>
<p><img alt="Query 40" src="../images/40.png" /></p>
<h3 id="41-find-large-functions-that-should-be-refactored">41. Find large functions that should be refactored</h3>
<ul>
<li><strong>Natural Language:</strong> "Find functions with more than 20 lines of code that might need refactoring."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function)\n    WHERE f.end_line - f.line_number &gt; 20\n    RETURN f&quot;
}
</code></pre>
<p><img alt="Query 41" src="../images/41.png" /></p>
<h3 id="42-find-recursive-functions">42. Find recursive functions</h3>
<ul>
<li><strong>Natural Language:</strong> "Find all functions that call themselves (recursive functions)."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH p=(f:Function)-[:CALLS]-&gt;(f2:Function)\n    WHERE f.name = f2.name AND f.file_path = f2.file_path\n    RETURN p&quot;
}
</code></pre>
<p><img alt="Query 42" src="../images/42.png" /></p>
<h3 id="43-find-most-connected-functions-hub-functions">43. Find most connected functions (hub functions)</h3>
<ul>
<li><strong>Natural Language:</strong> "Find the functions that are most central to the codebase (called by many and call many others)."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;MATCH (f:Function)\n    OPTIONAL MATCH (f)-[:CALLS]-&gt;(callee:Function)\n    OPTIONAL MATCH (caller:Function)-[:CALLS]-&gt;(f)\n    WITH f, count(DISTINCT callee) AS calls_out, count(DISTINCT caller) AS calls_in\n    ORDER BY (calls_out + calls_in) DESC\n    LIMIT 5\n    MATCH p=(f)-[*0..2]-()\n    RETURN p&quot;
}
</code></pre>
<p><img alt="Query 43" src="../images/43.png" /></p>
<h2 id="security-sensitive-data-analysis">Security &amp; Sensitive Data Analysis</h2>
<h3 id="44-find-potential-security-vulnerabilities-hardcoded-secrets">44. Find potential security vulnerabilities (hardcoded secrets)</h3>
<ul>
<li><strong>Natural Language:</strong> "Find potential hardcoded passwords, API keys, or secrets in the codebase."</li>
<li><strong>Tool:</strong> <code>execute_cypher_query</code></li>
<li><strong>JSON Arguments:</strong></li>
</ul>
<pre><code class="language-json">{
  &quot;cypher_query&quot;: &quot;WITH [\&quot;password\&quot;,  \&quot;api_key\&quot;, \&quot;apikey\&quot;,    \&quot;secret_token\&quot;, \&quot;token\&quot;, \&quot;auth\&quot;, \&quot;access_key\&quot;, \&quot;private_key\&quot;, \&quot;client_secret\&quot;, \&quot;sessionid\&quot;, \&quot;jwt\&quot;] AS keywords\n    MATCH (f:Function)\n    WHERE ANY(word IN keywords WHERE toLower(f.source_code) CONTAINS word)\n    RETURN f&quot;
}
</code></pre>












                
              </article>
            </div>
          
          
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
        </div>
        
      </main>
      
        <footer class="md-footer">
  
  <div class="md-footer-meta md-typeset">
    <div class="md-footer-meta__inner md-grid">
      <div class="md-copyright">
  
  
    Made with
    <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
      Material for MkDocs
    </a>
  
</div>
      
    </div>
  </div>
</footer>
      
    </div>
    <div class="md-dialog" data-md-component="dialog">
      <div class="md-dialog__inner md-typeset"></div>
    </div>
    
    
    
      
      <script id="__config" type="application/json">{"base": "..", "features": [], "search": "../assets/javascripts/workers/search.973d3a69.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": null}</script>
    
    
      <script src="../assets/javascripts/bundle.f55a23d4.min.js"></script>
      
    
  </body>
</html>
```

--------------------------------------------------------------------------------
/docs/site/search/search_index.json:
--------------------------------------------------------------------------------

```json
{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Welcome to CodeGraphContext","text":"<p>This is the official documentation for CodeGraphContext.</p>"},{"location":"#codegraphcontext","title":"CodeGraphContext","text":"<p>An MCP server that indexes local code into a graph database to provide context to AI assistants.</p>"},{"location":"#indexing-a-codebase","title":"Indexing a codebase","text":""},{"location":"#using-the-mcp-server","title":"Using the MCP server","text":""},{"location":"#project-details","title":"Project Details","text":"<ul> <li>Version: 0.1.15</li> <li>Authors: Shashank Shekhar Singh [email protected]</li> <li>License: MIT License (See LICENSE for details)</li> <li>Website: CodeGraphContext</li> </ul>"},{"location":"#star-history","title":"Star History","text":""},{"location":"#features","title":"Features","text":"<ul> <li>Code Indexing: Analyzes code and builds a knowledge graph of its components.</li> <li>Relationship Analysis: Query for callers, callees, class hierarchies, call chains and more.</li> <li>Live Updates: Watches local files for changes and automatically updates the graph.</li> <li>Interactive Setup: A user-friendly command-line wizard for easy setup.</li> <li>File Exclusion: Supports <code>.cgcignore</code> files to exclude specific files and directories from indexing.</li> </ul>"},{"location":"#used-by","title":"Used By","text":"<p>CodeGraphContext is already being explored by developers and projects for:</p> <ul> <li>Static code analysis in AI assistants</li> <li>Graph-based visualization of projects</li> <li>Dead code and complexity detection</li> </ul> <p>If you\u2019re using CodeGraphContext in your project, feel free to open a PR and add it here! \ud83d\ude80</p>"},{"location":"#dependencies","title":"Dependencies","text":"<ul> <li><code>neo4j&gt;=5.15.0</code></li> <li><code>watchdog&gt;=3.0.0</code></li> <li><code>requests&gt;=2.31.0</code></li> <li><code>stdlibs&gt;=2023.11.18</code></li> <li><code>typer[all]&gt;=0.9.0</code></li> <li><code>rich&gt;=13.7.0</code></li> <li><code>inquirerpy&gt;=0.3.4</code></li> <li><code>python-dotenv&gt;=1.0.0</code></li> <li><code>tree-sitter==0.20.4</code></li> <li><code>tree-sitter-languages==1.10.2</code></li> </ul>"},{"location":"#getting-started","title":"Getting Started","text":"<ol> <li>Install: <code>pip install codegraphcontext</code></li> <li> <p>Configure Your Environment:     Run the interactive setup wizard to connect to your database and configure your IDE:     <code>bash     cgc setup</code>     The wizard helps you with:</p> <ul> <li>Database Connection:<ul> <li>Docker (Recommended): Automatically sets up a local Neo4j instance.</li> <li>Linux Binary: Installs Neo4j directly on Debian-based systems.</li> <li>Hosted: Connects to a remote Neo4j database like AuraDB.</li> </ul> </li> <li>IDE Integration:<ul> <li>Automatically configures tools like VS Code, Cursor, Gemini CLI, and more.</li> <li>Generates the necessary <code>mcp.json</code> and <code>.env</code> files for you.</li> </ul> </li> </ul> </li> <li> <p>Start: <code>cgc start</code></p> </li> </ol>"},{"location":"#mcp-client-configuration","title":"MCP Client Configuration","text":"<p>The <code>cgc setup</code> command attempts to automatically configure your IDE/CLI. If you choose not to use the automatic setup, or if your tool is not supported, you can configure it manually.</p> <p>Add the following server configuration to your client's settings file (e.g., VS Code's <code>settings.json</code> or <code>.claude.json</code>):</p> <pre><code>{\n  \"mcpServers\": {\n    \"CodeGraphContext\": {\n      \"command\": \"cgc\",\n      \"args\": [\n        \"start\"\n      ],\n      \"env\": {\n        \"NEO4J_URI\": \"YOUR_NEO4J_URI\",\n        \"NEO4J_USERNAME\": \"YOUR_NEO4J_USERNAME\",\n        \"NEO4J_PASSWORD\": \"YOUR_NEO4J_PASSWORD\"\n      },\n      \"tools\": {\n        \"alwaysAllow\": [\n          \"add_code_to_graph\",\n          \"add_package_to_graph\",\n          \"check_job_status\",\n          \"list_jobs\",\n          \"find_code\",\n          \"analyze_code_relationships\",\n          \"watch_directory\",\n          \"find_dead_code\",\n          \"execute_cypher_query\",\n          \"calculate_cyclomatic_complexity\",\n          \"find_most_complex_functions\",\n          \"list_indexed_repositories\",\n          \"delete_repository\",\n          \"visualize_graph_query\",\n          \"list_watched_paths\",\n          \"unwatch_directory\"\n        ],\n        \"disabled\": false\n      },\n      \"disabled\": false,\n      \"alwaysAllow\": []\n    }\n  }\n}\n</code></pre>"},{"location":"#natural-language-interaction-examples","title":"Natural Language Interaction Examples","text":"<p>Once the server is running, you can interact with it through your AI assistant using plain English. Here are some examples of what you can say:</p>"},{"location":"#indexing-and-watching-files","title":"Indexing and Watching Files","text":"<ul> <li> <p>To index a new project:</p> <ul> <li>\"Please index the code in the <code>/path/to/my-project</code> directory.\" OR</li> <li>\"Add the project at <code>~/dev/my-other-project</code> to the code graph.\"</li> </ul> </li> <li> <p>To start watching a directory for live changes:</p> <ul> <li>\"Watch the <code>/path/to/my-active-project</code> directory for changes.\" OR</li> <li>\"Keep the code graph updated for the project I'm working on at <code>~/dev/main-app</code>.\"</li> </ul> <p>When you ask to watch a directory, the system performs two actions at once: 1.  It kicks off a full scan to index all the code in that directory. This process runs in the background, and you'll receive a <code>job_id</code> to track its progress. 2.  It begins watching the directory for any file changes to keep the graph updated in real-time.</p> <p>This means you can start by simply telling the system to watch a directory, and it will handle both the initial indexing and the continuous updates automatically.</p> </li> </ul>"},{"location":"#querying-and-understanding-code","title":"Querying and Understanding Code","text":"<ul> <li> <p>Finding where code is defined:</p> <ul> <li>\"Where is the <code>process_payment</code> function?\"</li> <li>\"Find the <code>User</code> class for me.\"</li> <li>\"Show me any code related to 'database connection'.\"</li> </ul> </li> <li> <p>Analyzing relationships and impact:</p> <ul> <li>\"What other functions call the <code>get_user_by_id</code> function?\"</li> <li>\"If I change the <code>calculate_tax</code> function, what other parts of the code will be affected?\"</li> <li>\"Show me the inheritance hierarchy for the <code>BaseController</code> class.\"</li> <li>\"What methods does the <code>Order</code> class have?\"</li> </ul> </li> <li> <p>Exploring dependencies:</p> <ul> <li>\"Which files import the <code>requests</code> library?\"</li> <li>\"Find all implementations of the <code>render</code> method.\"</li> </ul> </li> <li> <p>Advanced Call Chain and Dependency Tracking (Spanning Hundreds of Files):     The CodeGraphContext excels at tracing complex execution flows and dependencies across vast codebases. Leveraging the power of graph databases, it can identify direct and indirect callers and callees, even when a function is called through multiple layers of abstraction or across numerous files. This is invaluable for:</p> <ul> <li>Impact Analysis: Understand the full ripple effect of a change to a core function.</li> <li>Debugging: Trace the path of execution from an entry point to a specific bug.</li> <li> <p>Code Comprehension: Grasp how different parts of a large system interact.</p> </li> <li> <p>\"Show me the full call chain from the <code>main</code> function to <code>process_data</code>.\"</p> </li> <li>\"Find all functions that directly or indirectly call <code>validate_input</code>.\"</li> <li>\"What are all the functions that <code>initialize_system</code> eventually calls?\"</li> <li>\"Trace the dependencies of the <code>DatabaseManager</code> module.\"</li> </ul> </li> <li> <p>Code Quality and Maintenance:</p> <ul> <li>\"Is there any dead or unused code in this project?\"</li> <li>\"Calculate the cyclomatic complexity of the <code>process_data</code> function in <code>src/utils.py</code>.\"</li> <li>\"Find the 5 most complex functions in the codebase.\"</li> </ul> </li> <li> <p>Repository Management:</p> <ul> <li>\"List all currently indexed repositories.\"</li> <li>\"Delete the indexed repository at <code>/path/to/old-project</code>.\"</li> </ul> </li> </ul>"},{"location":"#social-coverage","title":"Social Coverage","text":"<ul> <li>Youtube: https://www.youtube.com/watch?v=KYYSdxhg1xU</li> <li>Blog: https://medium.com/@shashankshekharsingh1205/building-codegraphcontext-my-end-term-journey-in-summer-of-bitcoin-2025-422c9a4dc87e</li> <li>Twitter: https://x.com/braidpool/status/1968683721625637203</li> <li>PulseMCP: https://www.pulsemcp.com/servers/codegraphcontext</li> <li>MCPMarket: https://mcpmarket.com/server/codegraphcontext</li> <li>Playbooks: https://playbooks.com/mcp/codegraphcontext</li> <li>MCPHunt: https://mcp-hunt.com/mcp/server/codegraphcontext</li> <li>StackerNews: https://stacker.news/items/1227191</li> <li>Glama.ai: https://glama.ai/mcp/servers/@Shashankss1205/CodeGraphContext/blob/a346d340d8f705ce93626b4b322dd0e2823ba46b/src/codegraphcontext/core/jobs.py</li> </ul>"},{"location":"#contributing","title":"Contributing","text":"<p>Contributions are welcome! \ud83c\udf89 Please see our CONTRIBUTING.md for detailed guidelines. If you have ideas for new features, integrations, or improvements, open an issue or submit a Pull Request.</p> <p>Join discussions and help shape the future of CodeGraphContext.</p>"},{"location":"architecture/","title":"Architecture Documentation","text":"<p>This document provides a detailed overview of the architecture of the CodeGraphContext project.</p>"},{"location":"architecture/#high-level-overview","title":"High-Level Overview","text":"<p>The project is a client-server application designed to analyze and visualize codebases. It consists of:</p> <ul> <li>A Python backend: This is the core of the application, responsible for parsing and analyzing code, building a graph representation of the codebase, and exposing this data through an API.</li> <li>A web-based frontend: A user interface for interacting with the backend, visualizing the code graph, and exploring the codebase.</li> <li>A command-line interface (CLI): For managing the backend and performing analysis from the terminal.</li> </ul>"},{"location":"architecture/#backend-architecture","title":"Backend Architecture","text":"<p>The backend is a Python application located in the <code>src/codegraphcontext</code> directory.</p>"},{"location":"architecture/#core-components","title":"Core Components","text":"<p>The <code>src/codegraphcontext/core</code> directory contains the fundamental building blocks of the backend:</p> <ul> <li>Database: A graph database is used to store the code graph. This allows for efficient querying of relationships between code elements (e.g., function calls, class inheritance).</li> <li>Jobs: Asynchronous jobs are used for long-running tasks like indexing a new codebase. This prevents the application from becoming unresponsive.</li> <li>Watcher: A file system watcher monitors the codebase for changes and triggers re-indexing, keeping the code graph up-to-date.</li> </ul>"},{"location":"architecture/#tools","title":"Tools","text":"<p>The <code>src/codegraphcontext/tools</code> directory contains the logic for code analysis:</p> <ul> <li>Graph Builder: This component is responsible for parsing the code and building the graph representation that is stored in the database.</li> <li>Code Finder: Provides functionality to search for specific code elements within the indexed codebase.</li> <li>Import Extractor: This tool analyzes the import statements in the code to understand dependencies between modules.</li> </ul>"},{"location":"architecture/#server","title":"Server","text":"<p>The <code>src/codegraphcontext/server.py</code> file implements the API server. It exposes the functionality of the backend to the frontend through a JSON-RPC API.</p>"},{"location":"architecture/#cli","title":"CLI","text":"<p>The <code>src/codegraphcontext/cli</code> directory contains the implementation of the command-line interface. It allows users to:</p> <ul> <li>Start and stop the backend server.</li> <li>Index new projects.</li> <li>Run analysis tools from the command line.</li> </ul>"},{"location":"architecture/#frontend-architecture","title":"Frontend Architecture","text":"<p>The frontend is a modern web application located in the <code>website/</code> directory.</p> <ul> <li>Framework: It is built using React and TypeScript.</li> <li>Build Tool: Vite is used for fast development and building the application.</li> <li>Component-Based: The UI is organized into reusable components, located in <code>website/src/components</code>. This includes UI elements like buttons and dialogs, as well as higher-level components for different sections of the application.</li> <li>Styling: Tailwind CSS is used for styling the application.</li> </ul>"},{"location":"architecture/#testing","title":"Testing","text":"<p>The <code>tests/</code> directory contains the test suite for the project.</p> <ul> <li>Integration Tests: <code>test_cgc_integration.py</code> contains tests that verify the interaction between different components of the backend.</li> <li>Unit Tests: Other files in this directory contain unit tests for specific modules and functions.</li> <li>Sample Project: The <code>tests/sample_project</code> directory contains a variety of Python files used as input for testing the code analysis tools.</li> </ul>"},{"location":"cli/","title":"CLI Reference","text":"<p>The CodeGraphContext CLI provides a set of commands to manage the server, index your code, and interact with the code graph.</p>"},{"location":"cli/#cgc-setup","title":"<code>cgc setup</code>","text":"<p>Runs the interactive setup wizard to configure the server and database connection. This helps users set up a local Docker-based Neo4j instance or connect to a remote one.</p> <p>Usage:</p> <pre><code>cgc setup\n</code></pre>"},{"location":"cli/#cgc-start","title":"<code>cgc start</code>","text":"<p>Starts the CodeGraphContext MCP server, which listens for JSON-RPC requests from stdin.</p> <p>Usage:</p> <pre><code>cgc start\n</code></pre>"},{"location":"cli/#cgc-index-path","title":"<code>cgc index [PATH]</code>","text":"<p>Indexes a directory or file by adding it to the code graph. If no path is provided, it indexes the current directory.</p> <p>Arguments: *   <code>PATH</code> (optional): Path to the directory or file to index. Defaults to the current directory.</p> <p>Usage:</p> <pre><code>cgc index /path/to/your/project\n</code></pre>"},{"location":"cli/#ignoring-files-cgcignore","title":"Ignoring Files (<code>.cgcignore</code>)","text":"<p>You can tell CodeGraphContext to ignore specific files and directories by creating a <code>.cgcignore</code> file in the root of your project. This file uses the same syntax as <code>.gitignore</code>.</p> <p>When you run <code>cgc index</code>, the command will look for a <code>.cgcignore</code> file in the directory being indexed and exclude any files or directories that match the patterns in the file.</p> <p>Example <code>.cgcignore</code> file:</p> <pre><code># Ignore build artifacts\n/build/\n/dist/\n\n# Ignore dependencies\n/node_modules/\n/vendor/\n\n# Ignore logs\n*.log\n</code></pre>"},{"location":"cli/#cgc-delete-path","title":"<code>cgc delete &lt;PATH&gt;</code>","text":"<p>Deletes a repository from the code graph.</p> <p>Arguments: *   <code>PATH</code> (required): Path of the repository to delete from the code graph.</p> <p>Usage:</p> <pre><code>cgc delete /path/to/your/project\n</code></pre>"},{"location":"cli/#cgc-visualize-query","title":"<code>cgc visualize [QUERY]</code>","text":"<p>Generates a URL to visualize a Cypher query in the Neo4j Browser. If no query is provided, a default query will be used.</p> <p>Arguments: *   <code>QUERY</code> (optional): The Cypher query to visualize.</p> <p>Usage:</p> <pre><code>cgc visualize \"MATCH (n) RETURN n\"\n</code></pre>"},{"location":"cli/#cgc-list_repos","title":"<code>cgc list_repos</code>","text":"<p>Lists all indexed repositories.</p> <p>Usage:</p> <pre><code>cgc list_repos\n</code></pre>"},{"location":"cli/#cgc-add_package-package_name","title":"<code>cgc add_package &lt;PACKAGE_NAME&gt;</code>","text":"<p>Adds a Python package to the code graph.</p> <p>Arguments: *   <code>PACKAGE_NAME</code> (required): Name of the Python package to add.</p> <p>Usage:</p> <pre><code>cgc add_package requests\n</code></pre>"},{"location":"cli/#cgc-cypher-query","title":"<code>cgc cypher &lt;QUERY&gt;</code>","text":"<p>Executes a read-only Cypher query.</p> <p>Arguments: *   <code>QUERY</code> (required): The read-only Cypher query to execute.</p> <p>Usage:</p> <pre><code>cgc cypher \"MATCH (n:Function) RETURN n.name\"\n</code></pre>"},{"location":"cli/#cgc-list_mcp_tools","title":"<code>cgc list_mcp_tools</code>","text":"<p>Lists all available tools and their descriptions.</p> <p>Usage:</p> <pre><code>cgc list_mcp_tools\n</code></pre>"},{"location":"cli/#cgc-help","title":"<code>cgc help</code>","text":"<p>Show the main help message and exit.</p> <p>Usage:</p> <pre><code>cgc help\n</code></pre>"},{"location":"cli/#cgc-version","title":"<code>cgc version</code>","text":"<p>Show the application version.</p> <p>Usage:</p> <pre><code>cgc --version\n</code></pre> <p>or</p> <pre><code>cgc version\n</code></pre>"},{"location":"contributing/","title":"Contributing to CodeGraphContext","text":"<p>We welcome contributions! Please follow these steps:</p>"},{"location":"contributing/#general-guidelines","title":"General Guidelines","text":"<ul> <li>Ensure your code adheres to the existing style and conventions of the project.</li> <li>Write clear, concise, and well-documented code.</li> <li>All new features or bug fixes should be accompanied by appropriate tests.</li> <li>Keep your pull requests focused on a single feature or bug fix.</li> </ul>"},{"location":"contributing/#setting-up-your-development-environment","title":"Setting up Your Development Environment","text":"<ol> <li>Fork the repository.</li> <li>Set up your development environment: <code>pip install -e \".[dev]\"</code></li> <li>Create a new branch for your feature or bugfix (e.g., <code>git checkout -b feature/my-new-feature</code>).</li> </ol>"},{"location":"contributing/#debugging","title":"Debugging","text":"<p>To enable debug mode for detailed logging, locate the <code>debug_mode</code> variable in <code>src/codegraphcontext/tools/graph_builder.py</code> and set its value to <code>1</code>.</p> <pre><code># src/codegraphcontext/tools/graph_builder.py\ndebug_mode = 1\n</code></pre>"},{"location":"contributing/#running-tests","title":"Running Tests","text":"<p>Tests are located in the <code>tests/</code> directory and are run using <code>pytest</code>.</p> <ol> <li>Navigate to the root of the <code>CodeGraphContext</code> directory.</li> <li>Run all tests using the command: <code>pytest</code></li> <li>To run specific tests, you can provide the path to the test file, for example: <code>pytest tests/test_tools.py</code></li> <li>Skipping Re-indexing: To speed up test runs, especially during development, you can set the <code>CGC_SKIP_REINDEX</code> environment variable to <code>true</code>. This will prevent the test suite from re-indexing the sample project if it's already indexed.     <code>bash     CGC_SKIP_REINDEX=true pytest</code></li> </ol>"},{"location":"contributing/#submitting-changes","title":"Submitting Changes","text":"<ol> <li>Write your code and add corresponding tests in the <code>tests/</code> directory.</li> <li>Ensure all tests pass and your code lints without errors.</li> <li>Commit your changes with a descriptive commit message.</li> <li>Submit a pull request to the <code>main</code> branch.</li> </ol>"},{"location":"contributing_languages/","title":"Contributing New Language Support to CodeGraphContext","text":"<p>This document outlines the steps and best practices for adding support for a new programming language to CodeGraphContext. By following this guide, contributors can efficiently integrate new languages and leverage the Neo4j graph for verification.</p>"},{"location":"contributing_languages/#1-understanding-the-architecture","title":"1. Understanding the Architecture","text":"<p>CodeGraphContext uses a modular architecture for multi-language support:</p> <ul> <li>Generic <code>TreeSitterParser</code> (in <code>graph_builder.py</code>): This acts as a wrapper, dispatching parsing tasks to language-specific implementations.</li> <li>Language-Specific Parser Modules (in <code>src/codegraphcontext/tools/languages/</code>): Each language (e.g., Python, JavaScript) has its own module (e.g., <code>python.py</code>, <code>javascript.py</code>) containing:<ul> <li>Tree-sitter queries (<code>&lt;LANG&gt;_QUERIES</code>).</li> <li>A <code>&lt;Lang&gt;TreeSitterParser</code> class that encapsulates language-specific parsing logic.</li> <li>A <code>pre_scan_&lt;lang&gt;</code> function for initial symbol mapping.</li> </ul> </li> <li><code>GraphBuilder</code> (in <code>graph_builder.py</code>): Manages the overall graph building process, including file discovery, pre-scanning, and dispatching to the correct language parser.</li> </ul>"},{"location":"contributing_languages/#2-steps-to-add-a-new-language-eg-typescript-ts","title":"2. Steps to Add a New Language (e.g., TypeScript - <code>.ts</code>)","text":""},{"location":"contributing_languages/#step-21-create-the-language-module-file","title":"Step 2.1: Create the Language Module File","text":"<ol> <li>Create a new file: <code>src/codegraphcontext/tools/languages/typescript.py</code>.</li> <li>Add the necessary imports: <code>from pathlib import Path</code>, <code>from typing import Any, Dict, Optional, Tuple</code>, <code>import logging</code>, <code>import ast</code> (if needed for AST manipulation).</li> <li>Define <code>TS_QUERIES</code> (Tree-sitter queries for TypeScript).</li> <li>Create a <code>TypescriptTreeSitterParser</code> class.</li> <li>Create a <code>pre_scan_typescript</code> function.</li> </ol>"},{"location":"contributing_languages/#step-22-define-tree-sitter-queries-ts_queries","title":"Step 2.2: Define Tree-sitter Queries (<code>TS_QUERIES</code>)","text":"<p>This is the most critical and often iterative step. You'll need to define queries for:</p> <ul> <li><code>functions</code>: Function declarations, arrow functions, methods.</li> <li><code>classes</code>: Class declarations, class expressions.</li> <li><code>imports</code>: ES6 imports (<code>import ... from ...</code>), CommonJS <code>require()</code>.</li> <li><code>calls</code>: Function calls, method calls.</li> <li><code>variables</code>: Variable declarations (<code>let</code>, <code>const</code>, <code>var</code>).</li> <li><code>docstrings</code>: (Optional) How documentation comments are identified.</li> <li><code>lambda_assignments</code>: (Optional, Python-specific) If the language has similar constructs.</li> </ul> <p>Tips for Query Writing: *   Consult Tree-sitter Grammars: Find the <code>node-types.json</code> or grammar definition for your language (e.g., <code>tree-sitter-typescript</code>). *   Use <code>tree-sitter parse</code>: Use the <code>tree-sitter parse</code> command-line tool to inspect the AST of sample code snippets. This is invaluable for identifying correct node types and field names. *   Start Simple: Begin with basic queries and gradually add complexity. *   Test Iteratively: After each query, test it with sample code.</p>"},{"location":"contributing_languages/#step-23-implement-langtreesitterparser-class","title":"Step 2.3: Implement <code>&lt;Lang&gt;TreeSitterParser</code> Class","text":"<p>This class (e.g., <code>TypescriptTreeSitterParser</code>) will encapsulate the language-specific logic.</p> <ol> <li><code>__init__(self, generic_parser_wrapper)</code>:<ul> <li>Store <code>generic_parser_wrapper</code>, <code>language_name</code>, <code>language</code>, <code>parser</code> from the generic wrapper.</li> <li>Load <code>TS_QUERIES</code> using <code>self.language.query(query_str)</code>.</li> </ul> </li> <li>Helper Methods:<ul> <li><code>_get_node_text(self, node)</code>: Extracts text from a tree-sitter node.</li> <li><code>_get_parent_context(self, node, types=...)</code>: (Language-specific node types for context).</li> <li><code>_calculate_complexity(self, node)</code>: (Language-specific complexity nodes).</li> <li><code>_get_docstring(self, body_node)</code>: (Language-specific docstring extraction).</li> </ul> </li> <li><code>parse(self, file_path: Path, is_dependency: bool = False) -&gt; Dict</code>:<ul> <li>Reads the file, parses it with <code>self.parser</code>.</li> <li>Calls its own <code>_find_*</code> methods (<code>_find_functions</code>, <code>_find_classes</code>, etc.).</li> <li>Returns a standardized dictionary format (as seen in <code>python.py</code> and <code>javascript.py</code>).</li> </ul> </li> <li><code>_find_*</code> Methods:     Implement these for each query type, extracting data from the AST and populating the standardized dictionary.</li> </ol>"},{"location":"contributing_languages/#step-24-implement-pre_scan_lang-function","title":"Step 2.4: Implement <code>pre_scan_&lt;lang&gt;</code> Function","text":"<p>This function (e.g., <code>pre_scan_typescript</code>) will quickly scan files to build an initial <code>imports_map</code>.</p> <ol> <li>It takes <code>files: list[Path]</code> and <code>parser_wrapper</code> (an instance of <code>TreeSitterParser</code>).</li> <li>Uses a simplified query (e.g., for <code>class_declaration</code> and <code>function_declaration</code>) to quickly find definitions.</li> <li>Returns a dictionary mapping symbol names to file paths.</li> </ol>"},{"location":"contributing_languages/#step-25-integrate-into-graph_builderpy","title":"Step 2.5: Integrate into <code>graph_builder.py</code>","text":"<ol> <li><code>GraphBuilder.__init__</code>:<ul> <li>Add <code>'.ts': TreeSitterParser('typescript')</code> to <code>self.parsers</code>.</li> </ul> </li> <li><code>TreeSitterParser.__init__</code>:<ul> <li>Add an <code>elif self.language_name == 'typescript':</code> block to initialize <code>self.language_specific_parser</code> with <code>TypescriptTreeSitterParser(self)</code>.</li> </ul> </li> <li><code>GraphBuilder._pre_scan_for_imports</code>:<ul> <li>Add an <code>elif '.ts' in files_by_lang:</code> block to import <code>pre_scan_typescript</code> and call it.</li> </ul> </li> </ol>"},{"location":"contributing_languages/#3-verification-and-debugging-using-neo4j","title":"3. Verification and Debugging using Neo4j","text":"<p>After implementing support for a new language, it's crucial to verify that the graph is being built correctly.</p>"},{"location":"contributing_languages/#step-31-prepare-a-sample-project","title":"Step 3.1: Prepare a Sample Project","text":"<p>Create a small sample project for your new language (e.g., <code>tests/sample_project_typescript/</code>) with: *   Function declarations. *   Class declarations (including inheritance). *   Various import types (if applicable). *   Function calls. *   Variable declarations.</p>"},{"location":"contributing_languages/#step-32-index-the-sample-project","title":"Step 3.2: Index the Sample Project","text":"<ol> <li>Delete existing data (if any):     ```bash     # Replace with your sample project path     print(default_api.delete_repository(repo_path='/path/to/your/sample_project'))</li> <li>Index the project:     ```bash     # Replace with your sample project path     print(default_api.add_code_to_graph(path='/path/to/your/sample_project'))</li> <li>Monitor job status:     ```bash     # Use the job_id returned by add_code_to_graph     print(default_api.check_job_status(job_id=''))"},{"location":"contributing_languages/#step-33-query-the-neo4j-graph","title":"Step 3.3: Query the Neo4j Graph","text":"<p>Use Cypher queries to inspect the generated graph.</p> <ul> <li> <p>Check for Files and Language Tags: <code>cypher     MATCH (f:File)     WHERE f.path STARTS WITH '/path/to/your/sample_project'     RETURN f.name, f.path, f.lang</code> Expected: All files from your sample project should be listed with the correct <code>lang</code> tag.</p> </li> <li> <p>Check for Functions: <code>cypher     MATCH (f:File)-[:CONTAINS]-&gt;(fn:Function)     WHERE f.path STARTS WITH '/path/to/your/sample_project'       AND fn.lang = '&lt;your_language_name&gt;'     RETURN f.name AS FileName, fn.name AS FunctionName, fn.line_number AS Line</code> Expected: All functions from your sample project should be listed.</p> </li> <li> <p>Check for Classes: <code>cypher     MATCH (f:File)-[:CONTAINS]-&gt;(c:Class)     WHERE f.path STARTS WITH '/path/to/your/sample_project'       AND c.lang = '&lt;your_language_name&gt;'     RETURN f.name AS FileName, c.name AS ClassName, c.line_number AS Line</code> Expected: All classes from your sample project should be listed.</p> </li> <li> <p>Check for Imports (Module-level): <code>cypher     MATCH (f:File)-[:IMPORTS]-&gt;(m:Module)     WHERE f.path STARTS WITH '/path/to/your/sample_project'       AND f.lang = '&lt;your_language_name&gt;'     RETURN f.name AS FileName, m.name AS ImportedModule, m.full_import_name AS FullImportName</code> Expected: All module-level imports should be listed.</p> </li> <li> <p>Check for Function Calls: <code>cypher     MATCH (caller:Function)-[:CALLS]-&gt;(callee:Function)     WHERE caller.file_path STARTS WITH '/path/to/your/sample_project'       AND caller.lang = '&lt;your_language_name&gt;'     RETURN caller.name AS Caller, callee.name AS Callee, caller.file_path AS CallerFile, callee.file_path AS CalleeFile</code> Expected: All function calls should be correctly linked.</p> </li> <li> <p>Check for Class Inheritance: <code>cypher     MATCH (child:Class)-[:INHERITS]-&gt;(parent:Class)     WHERE child.file_path STARTS WITH '/path/to/your/sample_project'       AND child.lang = '&lt;your_language_name&gt;'     RETURN child.name AS ChildClass, parent.name AS ParentClass, child.file_path AS ChildFile, parent.file_path AS ParentFile</code> Expected: All inheritance relationships should be correctly linked.</p> </li> </ul>"},{"location":"contributing_languages/#step-34-debugging-common-issues","title":"Step 3.4: Debugging Common Issues","text":"<ul> <li><code>NameError: Invalid node type ...</code>: Your tree-sitter query is using a node type that doesn't exist in the language's grammar. Use <code>tree-sitter parse</code> to inspect the AST.</li> <li>Missing Relationships (e.g., <code>CALLS</code>, <code>IMPORTS</code>):<ul> <li>Check <code>_find_*</code> methods: Ensure your <code>_find_*</code> methods are correctly extracting the necessary data.</li> <li>Check <code>imports_map</code>: Verify that the <code>pre_scan_&lt;lang&gt;</code> function is correctly populating the <code>imports_map</code>.</li> <li>Check <code>local_imports</code> map: Ensure the <code>local_imports</code> map (built in <code>_create_function_calls</code> and <code>_create_inheritance_links</code>) is correctly resolving symbols.</li> </ul> </li> <li>Incorrect <code>lang</code> tags: Ensure <code>self.language_name</code> is correctly passed and stored.</li> </ul> <p>By following these steps, contributors can effectively add and verify new language support.</p>"},{"location":"cookbook/","title":"MCP Tool Cookbook","text":"<p>This cookbook provides examples of how to use the <code>mcp</code> tool to query and understand your Python codebase. The \"Tool\" indicates which <code>mcp</code> tool to use, and the \"JSON Arguments\" are what the LLM would provide to that tool.</p>"},{"location":"cookbook/#basic-queries","title":"Basic Queries","text":""},{"location":"cookbook/#1-find-a-specific-function-by-name","title":"1. Find a specific function by name","text":"<ul> <li>Natural Language: \"Where is the function <code>foo</code> defined?\"</li> <li>Tool: <code>find_code</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query\": \"foo\"\n}\n</code></pre>"},{"location":"cookbook/#2-find-all-calls-to-a-specific-function","title":"2. Find all calls to a specific function","text":"<ul> <li>Natural Language: \"Find all calls to the <code>helper</code> function.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_callers\",\n  \"target\": \"helper\"\n}\n</code></pre>"},{"location":"cookbook/#3-find-what-a-function-calls","title":"3. Find what a function calls","text":"<ul> <li>Natural Language: \"What functions are called inside the <code>foo</code> function?\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_callees\",\n  \"target\": \"foo\",\n  \"context\": \"/teamspace/studios/this_studio/demo/CodeGraphContext/tests/sample_project/module_a.py\"\n}\n</code></pre>"},{"location":"cookbook/#4-find-all-imports-of-a-specific-module","title":"4. Find all imports of a specific module","text":"<ul> <li>Natural Language: \"Where is the <code>math</code> module imported?\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_importers\",\n  \"target\": \"math\"\n}\n</code></pre>"},{"location":"cookbook/#5-find-all-methods-of-a-class","title":"5. Find all methods of a class","text":"<ul> <li>Natural Language: \"What are the methods of the <code>A</code> class?\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"class_hierarchy\",\n  \"target\": \"A\"\n}\n</code></pre> <ul> <li>Note: The response for <code>class_hierarchy</code> includes a list of methods.</li> </ul>"},{"location":"cookbook/#6-find-all-classes-that-inherit-from-a-specific-class","title":"6. Find all classes that inherit from a specific class","text":"<ul> <li>Natural Language: \"Show me all classes that inherit from <code>Base</code>.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"class_hierarchy\",\n  \"target\": \"Base\"\n}\n</code></pre> <ul> <li>Note: The response for <code>class_hierarchy</code> includes a list of child classes.</li> </ul>"},{"location":"cookbook/#7-find-all-functions-with-a-specific-decorator","title":"7. Find all functions with a specific decorator","text":"<ul> <li>Natural Language: \"Find all functions with the <code>log_decorator</code>.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_functions_by_decorator\",\n  \"target\": \"log_decorator\"\n}\n</code></pre>"},{"location":"cookbook/#8-find-all-dataclasses","title":"8. Find all dataclasses","text":"<ul> <li>Natural Language: \"Find all dataclasses.\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Class) WHERE 'dataclass' IN c.decorators RETURN c.name, c.file_path\"\n}\n</code></pre>"},{"location":"cookbook/#code-analysis-quality","title":"Code Analysis &amp; Quality","text":""},{"location":"cookbook/#9-find-the-5-most-complex-functions","title":"9. Find the 5 most complex functions","text":"<ul> <li>Natural Language: \"Find the 5 most complex functions.\"</li> <li>Tool: <code>find_most_complex_functions</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"limit\": 5\n}\n</code></pre>"},{"location":"cookbook/#10-calculate-cyclomatic-complexity-of-a-function","title":"10. Calculate cyclomatic complexity of a function","text":"<ul> <li>Natural Language: \"What is the cyclomatic complexity of <code>try_except_finally</code>?\"</li> <li>Tool: <code>calculate_cyclomatic_complexity</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"function_name\": \"try_except_finally\"\n}\n</code></pre>"},{"location":"cookbook/#11-find-unused-code","title":"11. Find unused code","text":"<ul> <li>Natural Language: \"Find unused code, but ignore API endpoints decorated with <code>@app.route</code>.\"</li> <li>Tool: <code>find_dead_code</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"exclude_decorated_with\": [\"@app.route\"]\n}\n</code></pre>"},{"location":"cookbook/#12-find-the-call-chain-between-two-functions","title":"12. Find the call chain between two functions","text":"<ul> <li>Natural Language: \"What is the call chain from <code>wrapper</code> to <code>helper</code>?\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"call_chain\",\n  \"target\": \"wrapper-&gt;helper\"\n}\n</code></pre>"},{"location":"cookbook/#13-find-all-direct-and-indirect-callers-of-a-function","title":"13. Find all direct and indirect callers of a function","text":"<ul> <li>Natural Language: \"Show me all functions that eventually call the <code>helper</code> function.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_all_callers\",\n  \"target\": \"helper\"\n}\n</code></pre>"},{"location":"cookbook/#14-find-functions-by-argument-name","title":"14. Find functions by argument name","text":"<ul> <li>Natural Language: \"Find all functions that take <code>self</code> as an argument.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_functions_by_argument\",\n  \"target\": \"self\"\n}\n</code></pre>"},{"location":"cookbook/#15-list-all-python-package-imports-from-a-directory","title":"15. List all python package imports from a directory","text":"<ul> <li>Natural Language: \"List all python package imports from my project directory.\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:File)-[:IMPORTS]-&gt;(m:Module) WHERE f.path ENDS WITH '.py' RETURN DISTINCT m.name\"\n}\n</code></pre>"},{"location":"cookbook/#repository-information-queries","title":"Repository Information Queries","text":""},{"location":"cookbook/#16-list-all-indexed-projects","title":"16. List all indexed projects","text":"<ul> <li>Natural Language: \"List all projects I have indexed.\"</li> <li>Tool: <code>list_indexed_repositories</code></li> <li>JSON Arguments:</li> </ul> <pre><code>  {}\n</code></pre>"},{"location":"cookbook/#17-check-the-status-of-an-indexing-job","title":"17. Check the status of an indexing job","text":"<ul> <li>Natural Language: \"What is the status of job <code>4cb9a60e-c1b1-43a7-9c94-c840771506bc</code>?\"</li> <li>Tool: <code>check_job_status</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"job_id\": \"4cb9a60e-c1b1-43a7-9c94-c840771506bc\"\n}\n</code></pre>"},{"location":"cookbook/#18-list-all-background-jobs","title":"18. List all background jobs","text":"<ul> <li>Natural Language: \"Show me all background jobs.\"</li> <li>Tool: <code>list_jobs</code></li> <li>JSON Arguments:</li> </ul> <pre><code>  {}\n</code></pre>"},{"location":"cookbook/#advanced-cypher-queries","title":"Advanced Cypher Queries","text":"<p>These examples use the <code>execute_cypher_query</code> tool for more specific and complex questions.</p>"},{"location":"cookbook/#19-find-all-function-definitions","title":"19. Find all function definitions","text":"<ul> <li>Natural Language: \"Find all function definitions in the codebase.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (n:Function) RETURN n.name, n.file_path, n.line_number LIMIT 50\"\n}\n</code></pre>"},{"location":"cookbook/#20-find-all-classes","title":"20. Find all classes","text":"<ul> <li>Natural Language: \"Show me all the classes.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (n:Class) RETURN n.name, n.file_path, n.line_number LIMIT 50\"\n}\n</code></pre>"},{"location":"cookbook/#21-find-all-functions-in-a-file","title":"21. Find all functions in a file","text":"<ul> <li>Natural Language: \"Find all functions in <code>module_a.py</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function) WHERE f.file_path ENDS WITH 'module_a.py' RETURN f.name\"\n}\n</code></pre>"},{"location":"cookbook/#22-find-all-classes-in-a-file","title":"22. Find all classes in a file","text":"<ul> <li>Natural Language: \"Find all classes in <code>advanced_classes.py</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Class) WHERE c.file_path ENDS WITH 'advanced_classes.py' RETURN c.name\"\n}\n</code></pre>"},{"location":"cookbook/#23-list-all-top-level-functions-and-classes-in-a-file","title":"23. List all top-level functions and classes in a file","text":"<ul> <li>Natural Language: \"List all top-level functions and classes in <code>module_a.py</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:File)-[:CONTAINS]-&gt;(n) WHERE f.name = 'module_a.py' AND (n:Function OR n:Class) AND n.context IS NULL RETURN n.name\"\n}\n</code></pre>"},{"location":"cookbook/#24-find-functions-in-one-module-that-call-a-function-in-another","title":"24. Find functions in one module that call a function in another","text":"<ul> <li>Natural Language: \"Find functions in <code>module_a.py</code> that call <code>helper</code> in <code>module_b.py</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (caller:Function)-[:CALLS]-&gt;(callee:Function {name: 'helper'}) WHERE caller.file_path ENDS WITH 'module_a.py' AND callee.file_path ENDS WITH 'module_b.py' RETURN caller.name\"\n}\n</code></pre>"},{"location":"cookbook/#25-find-circular-file-imports","title":"25. Find circular file imports","text":"<ul> <li>Natural Language: \"Are there any circular dependencies between files?\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f1:File)-[:IMPORTS]-&gt;(m2:Module), (f2:File)-[:IMPORTS]-&gt;(m1:Module) WHERE f1.name = m1.name + '.py' AND f2.name = m2.name + '.py' RETURN f1.name, f2.name\"\n}\n</code></pre>"},{"location":"cookbook/#26-find-all-functions-with-more-than-5-arguments","title":"26. Find all functions with more than 5 arguments","text":"<ul> <li>Natural Language: \"Find all functions with a large number of arguments.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function) WHERE size(f.args) &gt; 5 RETURN f.name, f.file_path, size(f.args) as arg_count\"\n}\n</code></pre>"},{"location":"cookbook/#27-find-all-functions-in-a-file-that-have-a-docstring","title":"27. Find all functions in a file that have a docstring","text":"<ul> <li>Natural Language: \"Find all functions in <code>module_a.py</code> that have a docstring.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function) WHERE f.file_path ENDS WITH 'module_a.py' AND f.docstring IS NOT NULL AND f.docstring &lt;&gt; '' RETURN f.name\"\n}\n</code></pre>"},{"location":"cookbook/#28-find-all-classes-that-have-a-specific-method","title":"28. Find all classes that have a specific method","text":"<ul> <li>Natural Language: \"Find all classes that have a <code>greet</code> method.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Class)-[:CONTAINS]-&gt;(m:Function {name: 'greet'}) RETURN c.name, c.file_path\"\n}\n</code></pre>"},{"location":"cookbook/#29-find-the-depth-of-inheritance-for-all-classes","title":"29. Find the depth of inheritance for all classes","text":"<ul> <li>Natural Language: \"How deep are the inheritance chains for all classes?\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Class) OPTIONAL MATCH path = (c)-[:INHERITS*]-&gt;(parent:Class) RETURN c.name, c.file_path, length(path) AS depth ORDER BY depth DESC\"\n}\n</code></pre>"},{"location":"cookbook/#30-find-all-functions-that-have-a-docstring","title":"30. Find all functions that have a docstring","text":"<ul> <li>Natural Language: \"Show me all functions that are documented.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function) WHERE f.docstring IS NOT NULL AND f.docstring &lt;&gt; '' RETURN f.name, f.file_path LIMIT 50\"\n}\n</code></pre>"},{"location":"cookbook/#31-find-all-decorated-methods-in-a-class","title":"31. Find all decorated methods in a class","text":"<ul> <li>Natural Language: \"Find all decorated methods in the <code>Child</code> class.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Class {name: 'Child'})-[:CONTAINS]-&gt;(m:Function) WHERE m.decorators IS NOT NULL AND size(m.decorators) &gt; 0 RETURN m.name\"\n}\n</code></pre>"},{"location":"cookbook/#32-find-the-number-of-functions-in-each-file","title":"32. Find the number of functions in each file","text":"<ul> <li>Natural Language: \"How many functions are in each file?\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function) RETURN f.file_path, count(f) AS function_count ORDER BY function_count DESC\"\n}\n</code></pre>"},{"location":"cookbook/#33-find-all-methods-that-override-a-parent-method","title":"33. Find all methods that override a parent method","text":"<ul> <li>Natural Language: \"Find all methods that are overridden from a parent class.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Class)-[:INHERITS]-&gt;(p:Class), (c)-[:CONTAINS]-&gt;(m:Function), (p)-[:CONTAINS]-&gt;(m_parent:Function) WHERE m.name = m_parent.name RETURN m.name as method, c.name as child_class, p.name as parent_class\"\n}\n</code></pre>"},{"location":"cookbook/#34-find-all-functions-that-call-super","title":"34. Find all functions that call <code>super()</code>","text":"<ul> <li>Natural Language: \"Find all methods that call their parent's method via <code>super()</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function)-[r:CALLS]-&gt;() WHERE r.full_call_name STARTS WITH 'super(' RETURN f.name, f.file_path\"\n}\n</code></pre>"},{"location":"cookbook/#35-find-all-calls-to-a-function-with-a-specific-argument","title":"35. Find all calls to a function with a specific argument","text":"<ul> <li>Natural Language: \"Find all calls to <code>helper</code> with the argument <code>x</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH ()-[r:CALLS]-&gt;(f:Function {name: 'helper'}) WHERE 'x' IN r.args RETURN r.full_call_name, r.line_number, r.file_path\"\n}\n</code></pre>"},{"location":"cookbook/#36-find-all-functions-that-are-not-called-by-any-other-function","title":"36. Find all functions that are not called by any other function","text":"<ul> <li>Natural Language: \"Find all dead code (functions that are never called).\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function) WHERE NOT (()-[:CALLS]-&gt;(f)) AND f.is_dependency = false RETURN f.name, f.file_path\"\n}\n</code></pre>"},{"location":"cookbook/#37-find-all-functions-that-are-called-with-a-specific-argument","title":"37. Find all functions that are called with a specific argument","text":"<ul> <li>Natural Language: \"Find all calls to <code>print</code> with the argument <code>'hello'</code>.\"</li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (c:Call) WHERE c.name = 'print' AND 'hello' IN c.args RETURN c.file, c.lineno\"\n}\n</code></pre>"},{"location":"cookbook/#38-find-all-direct-and-indirect-callees-of-a-function","title":"38. Find all direct and indirect callees of a function","text":"<ul> <li>Natural Language: \"Show me all functions that are eventually called by the <code>foo</code> function.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"find_all_callees\",\n  \"target\": \"foo\",\n  \"context\": \"/teamspace/studios/this_studio/demo/CodeGraphContext/tests/sample_project/module_a.py\"\n}\n</code></pre>"},{"location":"cookbook/#39-find-all-functions-that-are-overridden","title":"39. Find all functions that are overridden","text":"<ul> <li>Natural Language: \"Find all functions that are overridden.\"</li> <li>Tool: <code>analyze_code_relationships</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"query_type\": \"overrides\",\n  \"target\": \"foo\"\n}\n</code></pre>"},{"location":"cookbook/#40-find-all-modules-imported-by-module_a","title":"40. Find all modules imported by <code>module_a</code>","text":"<ul> <li>Natural Language: \"Find all modules imported by <code>module_a</code>.\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:File {name: 'module_a.py'})-[:IMPORTS]-&gt;(m:Module) RETURN m.name AS imported_module_name\"\n}\n</code></pre>"},{"location":"cookbook/#41-find-large-functions-that-should-be-refactored","title":"41. Find large functions that should be refactored","text":"<ul> <li>Natural Language: \"Find functions with more than 20 lines of code that might need refactoring.\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function)\\n    WHERE f.end_line - f.line_number &gt; 20\\n    RETURN f\"\n}\n</code></pre>"},{"location":"cookbook/#42-find-recursive-functions","title":"42. Find recursive functions","text":"<ul> <li>Natural Language: \"Find all functions that call themselves (recursive functions).\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH p=(f:Function)-[:CALLS]-&gt;(f2:Function)\\n    WHERE f.name = f2.name AND f.file_path = f2.file_path\\n    RETURN p\"\n}\n</code></pre>"},{"location":"cookbook/#43-find-most-connected-functions-hub-functions","title":"43. Find most connected functions (hub functions)","text":"<ul> <li>Natural Language: \"Find the functions that are most central to the codebase (called by many and call many others).\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"MATCH (f:Function)\\n    OPTIONAL MATCH (f)-[:CALLS]-&gt;(callee:Function)\\n    OPTIONAL MATCH (caller:Function)-[:CALLS]-&gt;(f)\\n    WITH f, count(DISTINCT callee) AS calls_out, count(DISTINCT caller) AS calls_in\\n    ORDER BY (calls_out + calls_in) DESC\\n    LIMIT 5\\n    MATCH p=(f)-[*0..2]-()\\n    RETURN p\"\n}\n</code></pre>"},{"location":"cookbook/#security-sensitive-data-analysis","title":"Security &amp; Sensitive Data Analysis","text":""},{"location":"cookbook/#44-find-potential-security-vulnerabilities-hardcoded-secrets","title":"44. Find potential security vulnerabilities (hardcoded secrets)","text":"<ul> <li>Natural Language: \"Find potential hardcoded passwords, API keys, or secrets in the codebase.\"</li> <li>Tool: <code>execute_cypher_query</code></li> <li>JSON Arguments:</li> </ul> <pre><code>{\n  \"cypher_query\": \"WITH [\\\"password\\\",  \\\"api_key\\\", \\\"apikey\\\",    \\\"secret_token\\\", \\\"token\\\", \\\"auth\\\", \\\"access_key\\\", \\\"private_key\\\", \\\"client_secret\\\", \\\"sessionid\\\", \\\"jwt\\\"] AS keywords\\n    MATCH (f:Function)\\n    WHERE ANY(word IN keywords WHERE toLower(f.source_code) CONTAINS word)\\n    RETURN f\"\n}\n</code></pre>"},{"location":"core/","title":"Core Concepts","text":"<p>The core of CodeGraphContext is built upon a few key components that manage the database connection, handle background tasks, and watch for file system changes.</p>"},{"location":"core/#databasemanager","title":"<code>DatabaseManager</code>","text":"<p>The <code>DatabaseManager</code> class in <code>database.py</code> is a thread-safe singleton responsible for managing the connection to the Neo4j database. This ensures that only one connection pool is created and shared across the application, which is crucial for performance and resource management.</p>"},{"location":"core/#key-methods","title":"Key Methods","text":"<ul> <li><code>get_driver()</code>: Returns the active Neo4j Driver instance, creating it if it doesn't exist.</li> <li><code>close_driver()</code>: Closes the Neo4j driver connection.</li> <li><code>is_connected()</code>: Checks if the database connection is currently active.</li> </ul>"},{"location":"core/#jobmanager","title":"<code>JobManager</code>","text":"<p>The <code>JobManager</code> class in <code>jobs.py</code> handles long-running, background jobs, such as code indexing. It stores job information in memory and provides a thread-safe way to create, update, and retrieve information about these jobs.</p>"},{"location":"core/#jobstatus","title":"<code>JobStatus</code>","text":"<p>An enumeration for the possible statuses of a background job: - <code>PENDING</code> - <code>RUNNING</code> - <code>COMPLETED</code> - <code>FAILED</code> - <code>CANCELLED</code></p>"},{"location":"core/#jobinfo","title":"<code>JobInfo</code>","text":"<p>A data class that holds all information about a single background job, including its ID, status, start/end times, progress, and any errors.</p>"},{"location":"core/#key-methods_1","title":"Key Methods","text":"<ul> <li><code>create_job()</code>: Creates a new job with a unique ID.</li> <li><code>update_job()</code>: Updates the information for a specific job.</li> <li><code>get_job()</code>: Retrieves the information for a single job.</li> <li><code>list_jobs()</code>: Returns a list of all jobs.</li> <li><code>cleanup_old_jobs()</code>: Removes old, completed jobs from memory.</li> </ul>"},{"location":"core/#codewatcher","title":"<code>CodeWatcher</code>","text":"<p>The <code>CodeWatcher</code> class in <code>watcher.py</code> implements the live file-watching functionality using the <code>watchdog</code> library. It observes directories for changes and triggers updates to the code graph.</p>"},{"location":"core/#repositoryeventhandler","title":"<code>RepositoryEventHandler</code>","text":"<p>A dedicated event handler for a single repository. It performs an initial scan and then uses a debouncing mechanism to efficiently handle file changes, creations, or deletions.</p>"},{"location":"core/#key-methods_2","title":"Key Methods","text":"<ul> <li><code>watch_directory()</code>: Schedules a directory to be watched for changes.</li> <li><code>unwatch_directory()</code>: Stops watching a directory.</li> <li><code>list_watched_paths()</code>: Returns a list of all currently watched directory paths.</li> <li><code>start()</code>: Starts the observer thread.</li> <li><code>stop()</code>: Stops the observer thread gracefully.</li> </ul>"},{"location":"future_work/","title":"Ongoing Concerns and Future Work","text":"<p>This page outlines some of the current limitations of CodeGraphContext and areas for future development.</p>"},{"location":"future_work/#semantic-search","title":"Semantic Search","text":"<p>The tool is smart enough to find and analyze a function through millions of code files, but the tool is not yet smart enough to understand that a user searching for \u201ccalculate_sum\u201d is also intending to look at the \u201ccalculate_addition\u201d function. This level of semantic similarity needs to be researched, developed, tested and eventually implemented by our tool.</p>"},{"location":"installation/","title":"Installation","text":""},{"location":"installation/#installation-guide","title":"\ud83e\udde9 Installation Guide","text":"<p>Welcome to CodeGraphContext! This guide provides a clear and seamless path to installing and configuring the tool, from prerequisites to launching your server.</p>"},{"location":"installation/#prerequisites","title":"\u2699\ufe0f Prerequisites","text":"<p>Ensure the following are installed before you begin:</p> <ul> <li>Python: Version 3.8 or higher.</li> <li>AI Agentic Coding Tool: An MCP-compatible AI assistant (e.g., Gemini, Claude) if you plan to use the MCP server.</li> </ul>"},{"location":"installation/#getting-started","title":"\ud83d\ude80 Getting Started","text":"<p>Follow these steps to set up CodeGraphContext effortlessly.</p>"},{"location":"installation/#1-install-from-pypi","title":"1. Install from PyPI","text":"<p>Install the <code>codegraphcontext</code> package directly from PyPI using pip:</p> <pre><code>pip install codegraphcontext\n</code></pre>"},{"location":"installation/#2-run-the-setup-wizard","title":"2. Run the Setup Wizard","text":"<p>Launch the interactive setup wizard to configure your Neo4j database and development environment:</p> <pre><code>cgc setup\n</code></pre> <p>The wizard guides you through a series of intuitive prompts to tailor your setup.</p>"},{"location":"installation/#step-by-step-guide-for-the-setup-wizard","title":"\ud83e\udded \"Step-by-Step Guide for the Setup Wizard\"","text":"<p>When you run <code>cgc setup</code>, the wizard offers a thoughtful journey through configuration. Follow these steps to complete your setup with ease:</p> <p>1. Select Your Database Location</p> <p>Choose where your Neo4j database will reside:</p> <ul> <li>Local (Recommended): Host Neo4j on your machine for simplicity.  </li> <li>Docker: With Docker installed, the wizard crafts a <code>docker-compose.yml</code> file and launches a Neo4j container seamlessly.  </li> <li>Local Binary: On Debian-based systems (e.g., Ubuntu) or Mac Systems, the wizard installs Neo4j directly with your permission.  </li> <li>Hosted: Connect to a remote Neo4j instance, such as AuraDB, by providing your database URI, username, and password.  </li> <li>Existing Instance: For an existing Neo4j server (local or remote), enter its connection credentials.</li> </ul> <p>2. Configure Your Development Environment</p> <p>Integrate CodeGraphContext with your preferred development tool for a harmonious workflow. Select from supported options:</p> <ul> <li>VS Code</li> <li>Cursor</li> <li>Windsurf</li> <li>Claude</li> <li>Gemini CLI</li> <li>ChatGPT Codex</li> <li>Cline</li> <li>RooCode</li> <li>Amazon Q Developer</li> </ul> <p>The wizard automatically updates configuration files to align with your choice. Upon completing the prompts, the wizard creates two essential files:</p> <ul> <li><code>mcp.json</code>: Placed in your working directory, this file configures the MCP server.  </li> <li><code>.env</code>: Stored securely in <code>~/.codegraphcontext</code>, this file safeguards your Neo4j credentials.</li> </ul> <p>These files ensure smooth communication between CodeGraphContext, your Neo4j instance, and your AI assistant.</p>"},{"location":"installation/#3-start-the-server","title":"3. Start the Server","text":"<p>Once configuration is complete, launch the MCP server with:</p> <pre><code>cgc start\n</code></pre> <p>Your CodeGraphContext server is now active, ready to power AI-assisted graph queries.</p>"},{"location":"installation/#next-steps","title":"Next Steps","text":"<p>With CodeGraphContext installed and configured, you\u2019re ready to explore its AI-powered capabilities. Happy coding \u2728!</p>"},{"location":"license/","title":"License","text":"<p>CodeGraphContext is licensed under the MIT License.</p> <pre><code>MIT License\n\nCopyright (c) 2025\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n</code></pre>"},{"location":"server/","title":"MCPServer","text":"<p>The <code>MCPServer</code> class is the core of the CodeGraphContext application. It orchestrates all the major components, including database management, background job tracking, file system watching, and tool handling.</p>"},{"location":"server/#initialization","title":"Initialization","text":"<p>The server is initialized with an asyncio event loop. Upon initialization, it sets up the following components:</p> <ul> <li><code>DatabaseManager</code>: Manages the connection to the Neo4j database.</li> <li><code>JobManager</code>: Tracks the status of background jobs, such as code indexing.</li> <li><code>CodeWatcher</code>: Monitors the file system for changes to keep the code graph up-to-date.</li> <li><code>GraphBuilder</code>: Builds the code graph from the source code.</li> <li><code>CodeFinder</code>: Provides tools for searching and analyzing the code graph.</li> </ul>"},{"location":"server/#tool-manifest","title":"Tool Manifest","text":"<p>The <code>MCPServer</code> exposes a set of tools to the AI assistant. These tools are defined in the <code>_init_tools</code> method. Here is a list of available tools:</p>"},{"location":"server/#add_code_to_graph","title":"<code>add_code_to_graph</code>","text":"<p>Performs a one-time scan of a local folder to add its code to the graph. Ideal for indexing libraries, dependencies, or projects not being actively modified. Returns a job ID for background processing.</p>"},{"location":"server/#check_job_status","title":"<code>check_job_status</code>","text":"<p>Check the status and progress of a background job.</p>"},{"location":"server/#list_jobs","title":"<code>list_jobs</code>","text":"<p>List all background jobs and their current status.</p>"},{"location":"server/#find_code","title":"<code>find_code</code>","text":"<p>Find relevant code snippets related to a keyword (e.g., function name, class name, or content).</p>"},{"location":"server/#analyze_code_relationships","title":"<code>analyze_code_relationships</code>","text":"<p>Analyze code relationships like 'who calls this function' or 'class hierarchy'. Supported query types include: find_callers, find_callees, find_all_callers, find_all_callees, find_importers, who_modifies, class_hierarchy, overrides, dead_code, call_chain, module_deps, variable_scope, find_complexity, find_functions_by_argument, find_functions_by_decorator.</p>"},{"location":"server/#watch_directory","title":"<code>watch_directory</code>","text":"<p>Performs an initial scan of a directory and then continuously monitors it for changes, automatically keeping the graph up-to-date. Ideal for projects under active development. Returns a job ID for the initial scan.</p>"},{"location":"server/#execute_cypher_query","title":"<code>execute_cypher_query</code>","text":"<p>This is an advanced tool for directly querying the underlying Neo4j graph using a read-only Cypher query. It should be used as a fallback when other tools cannot answer very specific or complex questions about the code graph.</p> <p>Schema Overview:</p> <p>The code graph has the following structure:</p> <ul> <li>Nodes:<ul> <li><code>Repository</code>: Represents a project repository.</li> <li><code>File</code>: Represents a single source code file.</li> <li><code>Module</code>: Represents a package or a module.</li> <li><code>Class</code>: Represents a class definition.</li> <li><code>Function</code>: Represents a function or method definition.</li> </ul> </li> <li>Properties:<ul> <li>Nodes have properties like <code>name</code>, <code>path</code>, <code>cyclomatic_complexity</code> (for functions), and <code>code</code>.</li> </ul> </li> <li>Relationships:<ul> <li><code>CONTAINS</code>: e.g., <code>(:File)-[:CONTAINS]-&gt;(:Function)</code></li> <li><code>CALLS</code>: e.g., <code>(:Function)-[:CALLS]-&gt;(:Function)</code></li> <li><code>IMPORTS</code>: e.g., <code>(:File)-[:IMPORTS]-&gt;(:Module)</code></li> <li><code>INHERITS</code>: e.g., <code>(:Class)-[:INHERITS]-&gt;(:Class)</code></li> </ul> </li> </ul>"},{"location":"server/#add_package_to_graph","title":"<code>add_package_to_graph</code>","text":"<p>Add a Python package to Neo4j graph by discovering its location. Returns immediately with job ID.</p>"},{"location":"server/#find_dead_code","title":"<code>find_dead_code</code>","text":"<p>Find potentially unused functions (dead code) across the entire indexed codebase, optionally excluding functions with specific decorators.</p>"},{"location":"server/#calculate_cyclomatic_complexity","title":"<code>calculate_cyclomatic_complexity</code>","text":"<p>Calculate the cyclomatic complexity of a specific function to measure its complexity.</p>"},{"location":"server/#find_most_complex_functions","title":"<code>find_most_complex_functions</code>","text":"<p>Find the most complex functions in the codebase based on cyclomatic complexity.</p>"},{"location":"server/#list_indexed_repositories","title":"<code>list_indexed_repositories</code>","text":"<p>List all indexed repositories.</p>"},{"location":"server/#delete_repository","title":"<code>delete_repository</code>","text":"<p>Delete an indexed repository from the graph.</p>"},{"location":"server/#visualize_graph_query","title":"<code>visualize_graph_query</code>","text":"<p>Generates a URL to visualize the results of a Cypher query in the Neo4j Browser. The user can open this URL in their web browser to see the graph visualization.</p>"},{"location":"server/#list_watched_paths","title":"<code>list_watched_paths</code>","text":"<p>Lists all directories currently being watched for live file changes.</p>"},{"location":"server/#unwatch_directory","title":"<code>unwatch_directory</code>","text":"<p>Stops watching a directory for live file changes.</p>"},{"location":"server/#other-methods","title":"Other Methods","text":"<ul> <li><code>get_database_status()</code>: Returns the current connection status of the Neo4j database.</li> <li><code>get_local_package_path(package_name)</code>: Finds the local installation path of a Python package.</li> <li><code>run()</code>: Runs the main server loop, listening for JSON-RPC requests from stdin.</li> <li><code>shutdown()</code>: Gracefully shuts down the server and its components.</li> </ul>"},{"location":"tools/","title":"Tools","text":"<p>The <code>tools</code> directory contains the logic for code analysis, including building the graph, finding code, and extracting imports.</p>"},{"location":"tools/#graphbuilder","title":"<code>GraphBuilder</code>","text":"<p>The <code>GraphBuilder</code> class in <code>graph_builder.py</code> is responsible for parsing the source code and building the graph representation that is stored in the Neo4j database.</p>"},{"location":"tools/#treesitterparser","title":"<code>TreeSitterParser</code>","text":"<p><code>GraphBuilder</code> uses the <code>TreeSitterParser</code> class, which is a generic parser wrapper for a specific language using the tree-sitter library. This allows CodeGraphContext to support multiple programming languages in a modular way.</p>"},{"location":"tools/#graph-building-process","title":"Graph Building Process","text":"<p>The graph building process consists of several steps:</p> <ol> <li>Pre-scan for Imports: A quick scan of all files to build a global map of where every symbol is defined.</li> <li>Parse Files: Each file is parsed in detail to extract its structure, including functions, classes, variables, and imports.</li> <li>Add Nodes to Graph: The extracted code elements are added to the graph as nodes.</li> <li>Create Relationships: Relationships between the nodes are created, such as <code>CALLS</code> for function calls and <code>INHERITS</code> for class inheritance.</li> </ol>"},{"location":"tools/#codefinder","title":"<code>CodeFinder</code>","text":"<p>The <code>CodeFinder</code> class in <code>code_finder.py</code> provides functionality to search for specific code elements and analyze their relationships within the indexed codebase.</p>"},{"location":"tools/#key-methods","title":"Key Methods","text":"<ul> <li><code>find_by_function_name()</code>: Finds functions by name.</li> <li><code>find_by_class_name()</code>: Finds classes by name.</li> <li><code>find_by_variable_name()</code>: Finds variables by name.</li> <li><code>find_by_content()</code>: Finds code by content matching in source or docstrings.</li> <li><code>find_related_code()</code>: Finds code related to a query using multiple search strategies.</li> <li><code>analyze_code_relationships()</code>: Analyzes different types of code relationships, such as callers, callees, importers, and class hierarchies.</li> </ul>"},{"location":"tools/#importextractor","title":"<code>ImportExtractor</code>","text":"<p>The <code>ImportExtractor</code> class in <code>import_extractor.py</code> is a utility for extracting package and module imports from source code files of various programming languages. It uses the most appropriate parsing technique for each language, such as AST for Python and regular expressions for JavaScript.</p>"},{"location":"tools/#tools-exploration","title":"Tools Exploration","text":"<p>There are a total of 14 tools available to the users, and here we have attached illustrative demos for each one of them.</p>"},{"location":"tools/#find_code-tool","title":"find_code Tool","text":"<p>The <code>find_code</code> tool allows users to search for code snippets, functions, classes, and variables within the codebase using natural language queries. This tool helps developers understand and navigate large codebases efficiently.</p> <p>Below is an embedded link to a demo video showcasing the usage of the <code>find_code</code> tool in action. </p>"},{"location":"tools/#watch_directory-tool","title":"watch_directory Tool","text":"<p>The <code>watch_directory</code> tool allows users to monitor a specified directory for file changes, additions, or deletions in real-time. It helps developers automate workflows such as triggering scripts, updating indexes, or syncing files whenever changes occur in the directory.</p> <p>Below is an embedded link to a demo video showcasing the usage of the <code>watch_directory</code> tool in a development environment.  </p>"},{"location":"tools/#analyze_code_relationships-tool","title":"analyze_code_relationships Tool","text":"<p>The <code>analyze_code_relationships</code> tool in CodeGraphContext is designed to let users query and explore the various relationships between code elements in a codebase, represented as a graph in Neo4j. </p>"},{"location":"tools/#relationship-types-that-can-be-analyzed","title":"Relationship Types That Can Be Analyzed","text":"<ul> <li>CALLS: Finds which functions call or are called by a function.</li> <li>CALLED_BY: Finds all functions that directly or indirectly call a target function (inverse of CALLS).</li> <li>INHERITS_FROM: Finds class inheritance relationships; which classes inherit from which.</li> <li>CONTAINS: Shows containment (which classes/functions are inside which modules or files).</li> <li>IMPLEMENTS: Shows which classes implement an interface.</li> <li>IMPORTS: Identifies which files or modules import a specific module.</li> <li>DEFINED_IN: Locates where an entity (function/class) is defined.</li> <li>HAS_ARGUMENT: Shows relationships from functions to their arguments.</li> <li>DECLARES: Finds variables declared in functions or classes.</li> </ul> <p>Below is an embedded link to a demo video showcasing the usage of the <code>analyse_code_relationships</code> tool.  </p>"},{"location":"troubleshooting/","title":"CodeGraphContext Troubleshooting Guide","text":"<p>Use this checklist whenever <code>cgc setup</code> or <code>cgc start</code> doesn\u2019t behave as expected. It keeps the happy path short, but includes the fallback steps when something goes wrong.</p>"},{"location":"troubleshooting/#1-prerequisites-at-a-glance","title":"1. Prerequisites at a glance","text":"<ul> <li>Windows + PowerShell commands below assume the <code>py</code> launcher. Adapt to <code>python3</code> if you\u2019re on macOS/Linux.</li> <li>Python 3.11 (recommended). Run <code>py -3.11 --version</code> to confirm.</li> <li>Neo4j account (only required if you prefer Neo4j AuraDB instead of Docker).</li> </ul>"},{"location":"troubleshooting/#2-create-and-activate-a-virtual-environment","title":"2. Create and activate a virtual environment","text":"<p>From the repository root (<code>CodeGraphContext/</code>):</p> <pre><code>py -3.11 -m venv venv\n.\\venv\\Scripts\\python.exe -m pip install --upgrade pip\n</code></pre> <ul> <li>On Windows, Neo4j driver 6.x can crash with <code>AttributeError: socket.EAI_ADDRFAMILY</code>. If you see that, run:   <code>powershell   .\\venv\\Scripts\\python.exe -m pip install \"neo4j&lt;6\"</code></li> </ul>"},{"location":"troubleshooting/#3-run-the-setup-wizard-preferred","title":"3. Run the setup wizard (preferred)","text":"<p>Launch the wizard:</p> <pre><code>.\\venv\\Scripts\\cgc.exe setup\n</code></pre> <p>Tip: If you want the wizard to spin up a local Neo4j instance for you, make sure Docker Desktop is installed and running before you launch <code>cgc setup</code>. If Docker isn\u2019t running, the setup wizard will fail when it tries to install Neo4j locally.</p> <p>What happens next:</p> <ul> <li>The wizard checks for Docker. If it\u2019s running, it can auto-provision a local Neo4j instance for you.</li> <li>Alternatively, you can supply credentials for an existing Neo4j AuraDB database.</li> <li>At the end, it generates:</li> <li><code>mcp.json</code> in your project directory (stores the MCP server command + env vars).</li> <li><code>~/.codegraphcontext/.env</code> containing <code>NEO4J_URI</code>, <code>NEO4J_USERNAME</code>, <code>NEO4J_PASSWORD</code>.</li> </ul> <p>Make sure the Docker container (or remote Neo4j) is still running before you start the server.</p>"},{"location":"troubleshooting/#4-start-the-mcp-server","title":"4. Start the MCP server","text":"<p>Once the wizard completes successfully:</p> <pre><code>.\\venv\\Scripts\\cgc.exe start\n</code></pre> <p>Expected output includes:</p> <pre><code>Starting CodeGraphContext Server...\n...\nMCP Server is running. Waiting for requests...\n</code></pre> <p>If you instead see:</p> <pre><code>Configuration Error: Neo4j credentials must be set via environment variables\n</code></pre> <p>then either no credentials were saved, or the wizard was skipped\u2014see the manual alternative below.</p>"},{"location":"troubleshooting/#5-manual-credential-setup-fallback","title":"5. Manual credential setup (fallback)","text":"<p>If you prefer not to use the wizard or need to fix a broken configuration:</p> <ol> <li>Create a <code>mcp.json</code> (or edit the one that exists) in the repository root:</li> </ol> <p><code>json    {      \"mcpServers\": {        \"CodeGraphContext\": {          \"command\": \"cgc\",          \"args\": [\"start\"],          \"env\": {            \"NEO4J_URI\": \"neo4j+s://YOUR-HOSTNAME:7687\",            \"NEO4J_USERNAME\": \"neo4j\",            \"NEO4J_PASSWORD\": \"super-secret-password\"          }        }      }    }</code></p> <ol> <li> <p>(Optional) Also create <code>%USERPROFILE%\\.codegraphcontext\\.env</code> with the same key/value pairs. The CLI loads that file automatically.</p> </li> <li> <p>Re-run:</p> </li> </ol> <p><code>powershell    .\\venv\\Scripts\\cgc.exe start</code></p>"},{"location":"troubleshooting/#6-common-issues-fixes","title":"6. Common issues &amp; fixes","text":"Symptom Likely Cause Fix <code>Configuration Error: Neo4j credentials must be set\u2026</code> <code>mcp.json</code>/<code>.env</code> missing or empty Run <code>cgc setup</code> again with Docker running, or create the files manually (section 5). <code>AttributeError: socket.EAI_ADDRFAMILY</code> Neo4j 6.x bug on Windows Install the 5.x driver: <code>.\\venv\\Scripts\\python.exe -m pip install \"neo4j&lt;6\"</code> and retry. Setup wizard fails while pulling Docker image Docker Desktop not running or Docker permissions missing Start Docker Desktop, wait for it to report \u201cRunning\u201d, then rerun <code>cgc setup</code>. Server exits immediately with no log Neo4j instance is offline Check Docker container status or AuraDB dashboard; restart Neo4j and call <code>cgc start</code> again."},{"location":"troubleshooting/#7-after-the-server-is-running","title":"7. After the server is running","text":"<ul> <li>Keep the virtual environment active whenever you run <code>cgc</code> commands.</li> <li>Use <code>pytest</code> from the same env to run tests:</li> </ul> <p><code>powershell   .\\venv\\Scripts\\pytest</code></p> <ul> <li>Front-end website lives under <code>website/</code> if you need to run <code>npm run dev</code>.</li> </ul> <p>When in doubt, re-run the wizard with Docker active\u2014it regenerates the configuration files without touching your code. Let me know if any section needs clarifying! :)</p>"},{"location":"use_cases/","title":"Real World Use Cases","text":"<p>CodeGraphContext can be a powerful ally in your daily coding journey. Here are some real-world scenarios where it can significantly boost your productivity and understanding of a codebase:</p> <ol> <li> <p>Onboarding New Developers: A new team member can quickly get up to speed by asking questions like:</p> <ul> <li>\"Where is the authentication logic handled?\"</li> <li>\"Show me the main entry point of the application.\"</li> </ul> </li> <li> <p>Impact Analysis: Before making a change, assess the potential ripple effects:</p> <ul> <li>\"What other parts of the code will be affected if I change the <code>calculate_total</code> function?\"</li> </ul> </li> <li> <p>Code Review: Gain context on pull requests faster:</p> <ul> <li>\"Show me the callers of this new function.\"</li> <li>\"Does this change introduce any new dependencies?\"</li> </ul> </li> <li> <p>Debugging: Trace execution flows to pinpoint the source of a bug:</p> <ul> <li>\"Show me the call chain from <code>handle_request</code> to <code>process_payment</code>.\"</li> </ul> </li> <li> <p>Refactoring: Identify and plan large-scale code changes:</p> <ul> <li>\"Find all instances of the deprecated <code>OldApiClass</code>.\"</li> <li>\"List all functions that use the <code>urllib</code> library so I can replace them with <code>requests</code>.\"</li> </ul> </li> <li> <p>Identifying Code Smells: Proactively find areas that need improvement:</p> <ul> <li>\"Find the 10 most complex functions in the codebase.\"</li> <li>\"Show me functions with more than 5 arguments.\"</li> </ul> </li> <li> <p>Security Audits: Search for potentially vulnerable code patterns:</p> <ul> <li>\"Find all functions that use the <code>eval</code> function.\"</li> <li>\"Show me where raw SQL queries are being executed.\"</li> </ul> </li> <li> <p>Automated Documentation: Use the tool's understanding of the code to generate documentation. (This is what this agent is doing!)</p> </li> <li> <p>Dependency Management: Understand how your project uses its dependencies:</p> <ul> <li>\"Which files import the <code>requests</code> library?\"</li> <li>\"Are there any circular dependencies between modules?\"</li> </ul> </li> <li> <p>Cleaning Up Unused Code: Keep your codebase lean and maintainable:</p> <ul> <li>\"Is there any dead or unused code in this project?\"</li> </ul> </li> <li> <p>Exploring a Large Codebase: Navigate large, unfamiliar projects with ease:</p> <ul> <li>\"List all the classes in the <code>core</code> module.\"</li> <li>\"What are the top-level functions in the <code>utils</code> directory?\"</li> </ul> </li> <li> <p>Enforcing Coding Standards: Check for adherence to team conventions:</p> <ul> <li>\"Find all functions that are not decorated with <code>@log_execution</code>.\"</li> <li>\"Show me all public methods that don't have a docstring.\"</li> </ul> </li> <li> <p>Discovering API Usage: Find examples of how to use internal or external APIs:</p> <ul> <li>\"Show me how other parts of the code use the <code>UserService</code>.\"</li> </ul> </li> <li> <p>Improving Test Coverage: Identify areas that may lack test coverage:</p> <ul> <li>\"Find all functions that are not called by any test files.\"</li> </ul> </li> <li> <p>Visualizing Code Structure: Get a bird's-eye view of your project's architecture:</p> <ul> <li>\"Generate a graph visualization of the <code>auth</code> module and its dependencies.\"</li> </ul> </li> <li> <p>Learning a New Framework: Understand how a new framework operates by exploring its source code.</p> </li> <li> <p>Code Archeology: Investigate legacy code to understand its history and purpose.</p> </li> <li> <p>Planning a Migration: Identify all points of contact when migrating a library or framework:</p> <ul> <li>\"Find all the places where the <code>old_payment_gateway</code> is used.\"</li> </ul> </li> <li> <p>Knowledge Sharing: Use the code graph as a centralized, always-up-to-date knowledge base for your team.</p> </li> <li> <p>Automated Code Reviews: Integrate CodeGraphContext into your CI/CD pipeline to automatically flag potential issues in pull requests.</p> </li> </ol>"}]}
```
Page 12/14FirstPrevNextLast