codegraphcontext 0.5.2__tar.gz → 0.5.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codegraphcontext-0.5.2/src/codegraphcontext.egg-info → codegraphcontext-0.5.4}/PKG-INFO +53 -7
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/README.md +47 -1
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/pyproject.toml +27 -6
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/api/app.py +24 -5
- codegraphcontext-0.5.4/src/codegraphcontext/api/auth.py +123 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/api/mcp_sse.py +49 -2
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/api/router.py +9 -5
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/cli/cli_helpers.py +288 -75
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/cli/config_manager.py +59 -14
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/cli/hook_manager.py +26 -4
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/cli/main.py +217 -20
- codegraphcontext-0.5.4/src/codegraphcontext/cli/project_config.py +218 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/cli/registry_commands.py +6 -6
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/cli/setup_wizard.py +5 -0
- codegraphcontext-0.5.4/src/codegraphcontext/cli/simulator.py +343 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/__init__.py +70 -48
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/bundle_registry.py +45 -6
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/cgc_bundle.py +130 -34
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/cgcignore.py +29 -11
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/database.py +5 -1
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/database_embedded_kuzu.py +49 -3
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/database_falkordb.py +178 -40
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/database_falkordb_remote.py +31 -11
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/database_nornic.py +5 -1
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/falkor_worker.py +16 -3
- codegraphcontext-0.5.4/src/codegraphcontext/core/simulator.py +589 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/watcher.py +77 -14
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/prompts.py +52 -2
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/server.py +77 -4
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tool_definitions.py +183 -22
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/advanced_language_query_tool.py +2 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/code_finder.py +54 -38
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/graph_builder.py +50 -14
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/handlers/analysis_handlers.py +28 -9
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/handlers/management_handlers.py +33 -7
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/handlers/query_handlers.py +10 -4
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/discovery.py +6 -2
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/embeddings.py +8 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/persistence/writer.py +132 -137
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/pipeline.py +103 -21
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/pre_scan.py +20 -2
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/resolution/calls.py +31 -7
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/resolution/inheritance.py +16 -2
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/resolution/post_resolution.py +20 -20
- codegraphcontext-0.5.4/src/codegraphcontext/tools/indexing/schema.py +156 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/schema_contract.py +1 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/c.py +1 -1
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/cpp.py +1 -1
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/css.py +1 -1
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/dart.py +1 -1
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/elisp.py +1 -1
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/elixir.py +3 -3
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/go.py +3 -3
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/html.py +1 -1
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/javascript.py +32 -27
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/lua.py +1 -1
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/perl.py +1 -1
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/python.py +78 -44
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/ruby.py +2 -2
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/rust.py +1 -1
- codegraphcontext-0.5.4/src/codegraphcontext/tools/languages/sfc_common.py +240 -0
- codegraphcontext-0.5.4/src/codegraphcontext/tools/languages/solidity.py +1069 -0
- codegraphcontext-0.5.4/src/codegraphcontext/tools/languages/solidity_remappings.py +157 -0
- codegraphcontext-0.5.4/src/codegraphcontext/tools/languages/svelte.py +38 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/typescript.py +31 -27
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/typescriptjsx.py +3 -3
- codegraphcontext-0.5.4/src/codegraphcontext/tools/languages/vue.py +38 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/cpp_toolkit.py +22 -18
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/java_toolkit.py +1 -1
- codegraphcontext-0.5.4/src/codegraphcontext/tools/query_tool_languages/solidity_toolkit.py +70 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/report_generator.py +7 -7
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/system.py +13 -16
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/tree_sitter_parser.py +3 -0
- codegraphcontext-0.5.4/src/codegraphcontext/utils/cypher_ddl.py +80 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/utils/cypher_readonly.py +32 -6
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/utils/tree_sitter_manager.py +7 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/assets/__vite-browser-external-9wXp6ZBx.js +1 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/assets/function-calls-BtRHrqa2.png +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/assets/graph-total-D1fBAugo.png +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/assets/hero-graph-2voMJp2a.jpg +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/assets/hierarchy-DGADo0YT.png +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/assets/index-C-187lf0.js +5587 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/assets/index-fNAa6jgv.css +1 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/assets/parser-pyodide.worker-BgsDfaad.js +370 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/assets/parser.worker-_nvrecvj.js +233 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/assets/tree-sitter-qKYAACSa.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/cgcIcon.png +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/favicon.ico +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/index.html +32 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/logo-icon.svg +85 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/logo.svg +100 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/placeholder.svg +1 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/preview-image.png +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/robots.txt +14 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-c.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-c_sharp.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-core.js +1 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-cpp.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-dart.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-go.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-java.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-javascript.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-kotlin.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-perl.wasm +1 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-php.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-python.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-ruby.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-rust.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-swift.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-tsx.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter-typescript.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/tree-sitter.wasm +0 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/web-tree-sitter.js +4007 -0
- codegraphcontext-0.5.4/src/codegraphcontext/viz/dist/wasm/web-tree-sitter.wasm +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/viz/server.py +54 -12
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4/src/codegraphcontext.egg-info}/PKG-INFO +53 -7
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext.egg-info/SOURCES.txt +49 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext.egg-info/requires.txt +5 -3
- codegraphcontext-0.5.2/src/codegraphcontext/tools/indexing/schema.py +0 -114
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/LICENSE +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/MANIFEST.in +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/setup.cfg +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/__init__.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/__main__.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/api/__init__.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/api/schemas.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/cli/__init__.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/cli/setup_macos.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/cli/visualizer.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/database_kuzu.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/database_ladybug.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/graph_query.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/core/jobs.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/stdlibs.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/__init__.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/datasources/__init__.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/datasources/cassandra_ingester.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/datasources/mysql_ingester.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/datasources/redis_ingester.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/handlers/indexing_handlers.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/handlers/watcher_handlers.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/__init__.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/constants.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/persistence/__init__.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/persistence/utils.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/resolution/__init__.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/sanitize.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/scip_pipeline.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/indexing/vector_resolver.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/csharp.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/gradle.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/haskell.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/java.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/kotlin.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/maven.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/mybatis.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/php.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/scala.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/languages/swift.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/package_resolver.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/c_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/csharp_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/dart_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/elisp_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/go_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/haskell_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/javascript_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/perl_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/python_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/ruby_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/rust_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/scala_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/swift_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/query_tool_languages/typescript_toolkit.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/scip_indexer.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/scip_pb2.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/tools/type_utils.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/utils/debug_log.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/utils/gcf_encoder.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/utils/git_utils.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/utils/path_ignore.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/utils/path_sandbox.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/utils/repo_path.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/utils/tool_limits.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext/utils/visualize_graph.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext.egg-info/dependency_links.txt +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext.egg-info/entry_points.txt +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/src/codegraphcontext.egg-info/top_level.txt +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/tests/test_issue_806_fix.py +0 -0
- {codegraphcontext-0.5.2 → codegraphcontext-0.5.4}/tests/test_mcp_sse.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codegraphcontext
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.4
|
|
4
4
|
Summary: An MCP server that indexes local code into a graph database to provide context to AI assistants.
|
|
5
5
|
Author-email: Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -25,8 +25,8 @@ License: MIT License
|
|
|
25
25
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
26
|
SOFTWARE.
|
|
27
27
|
|
|
28
|
-
Project-URL: Homepage, https://github.com/
|
|
29
|
-
Project-URL: Bug Tracker, https://github.com/
|
|
28
|
+
Project-URL: Homepage, https://github.com/CodeGraphContext/CodeGraphContext
|
|
29
|
+
Project-URL: Bug Tracker, https://github.com/CodeGraphContext/CodeGraphContext/issues
|
|
30
30
|
Classifier: Programming Language :: Python :: 3
|
|
31
31
|
Classifier: Programming Language :: Python :: 3.10
|
|
32
32
|
Classifier: Programming Language :: Python :: 3.11
|
|
@@ -60,9 +60,9 @@ Requires-Dist: falkordb<1.6,>=1.0
|
|
|
60
60
|
Requires-Dist: falkordblite<0.10,>=0.7; sys_platform != "win32" and python_version >= "3.12"
|
|
61
61
|
Requires-Dist: requests>=2.28.0
|
|
62
62
|
Requires-Dist: protobuf<3.21,>=3.20
|
|
63
|
-
Requires-Dist: kuzu;
|
|
63
|
+
Requires-Dist: kuzu; python_version < "3.14" or sys_platform == "linux"
|
|
64
64
|
Requires-Dist: ladybug; sys_platform == "win32" or (sys_platform != "win32" and python_version >= "3.10")
|
|
65
|
-
Requires-Dist: mcp
|
|
65
|
+
Requires-Dist: mcp<2,>=1.0.0
|
|
66
66
|
Requires-Dist: fastapi>=0.100.0
|
|
67
67
|
Requires-Dist: uvicorn>=0.22.0
|
|
68
68
|
Provides-Extra: parsing
|
|
@@ -77,7 +77,7 @@ Provides-Extra: falkordb-remote
|
|
|
77
77
|
Requires-Dist: falkordb<1.6,>=1.0; extra == "falkordb-remote"
|
|
78
78
|
Requires-Dist: redis<6,>=5; extra == "falkordb-remote"
|
|
79
79
|
Provides-Extra: kuzu
|
|
80
|
-
Requires-Dist: kuzu; (
|
|
80
|
+
Requires-Dist: kuzu; (python_version < "3.14" or sys_platform == "linux") and extra == "kuzu"
|
|
81
81
|
Provides-Extra: ladybug
|
|
82
82
|
Requires-Dist: ladybug; (sys_platform == "win32" or (sys_platform != "win32" and python_version >= "3.10")) and extra == "ladybug"
|
|
83
83
|
Provides-Extra: neo4j
|
|
@@ -107,6 +107,7 @@ Dynamic: license-file
|
|
|
107
107
|
- 🇺🇦 [Українська](docs/translations/README.uk.md)
|
|
108
108
|
- 🇷🇺 [Русский](docs/translations/README.ru-RU.md)
|
|
109
109
|
- 🇯🇵 [日本語](docs/translations/README.ja.md)
|
|
110
|
+
- 🇮🇳 [தமிழ்](docs/translations/README.ta.md)
|
|
110
111
|
- 🇪🇸 Español (Soon)
|
|
111
112
|
|
|
112
113
|
🌍 **Help translate CodeGraphContext to your language by raising an issue & PR on [GitHub Issues](https://github.com/CodeGraphContext/CodeGraphContext/issues)!**
|
|
@@ -271,6 +272,49 @@ flowchart LR
|
|
|
271
272
|
- **Flexible Database Backend:** FalkorDB Lite (Default), KuzuDB, LadybugDB, FalkorDB Remote, Nornic DB, or Neo4j (all platforms via Docker/native).
|
|
272
273
|
|
|
273
274
|
|
|
275
|
+
---
|
|
276
|
+
## Architecture Overview
|
|
277
|
+
|
|
278
|
+
CodeGraphContext transforms source code into a queryable knowledge graph that can be explored through the CLI or AI assistants via MCP.
|
|
279
|
+
|
|
280
|
+
```mermaid
|
|
281
|
+
flowchart TD
|
|
282
|
+
A[Code Repository] --> B[Tree-sitter / SCIP Indexing]
|
|
283
|
+
B --> C[Knowledge Graph]
|
|
284
|
+
C --> D[Graph Database]
|
|
285
|
+
D --> E[CLI Toolkit]
|
|
286
|
+
D --> F[MCP Server]
|
|
287
|
+
F --> G[AI Assistant]
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Workflow
|
|
291
|
+
|
|
292
|
+
1. Source code is parsed using Tree-sitter or SCIP indexers.
|
|
293
|
+
2. Relationships between functions, classes, imports, and calls are extracted.
|
|
294
|
+
3. A knowledge graph is generated and stored in a graph database.
|
|
295
|
+
4. Users can query the graph through the CLI or AI assistants using MCP.
|
|
296
|
+
|
|
297
|
+
## 🏗️ Architecture & Workflow
|
|
298
|
+
|
|
299
|
+
CodeGraphContext parses your source code and builds a comprehensive knowledge graph. This graph can be queried directly via the CLI toolkit or exposed to AI assistants through the MCP server.
|
|
300
|
+
|
|
301
|
+
```mermaid
|
|
302
|
+
flowchart TD
|
|
303
|
+
A[Code Repository] -->|Parsed by| B[Tree-sitter / SCIP Indexing]
|
|
304
|
+
B -->|Generates| C[Knowledge Graph]
|
|
305
|
+
C -->|Stored in| D[(Graph Database)]
|
|
306
|
+
D -->|Queried via| E[CLI Toolkit]
|
|
307
|
+
D -->|Served by| F[MCP Server]
|
|
308
|
+
F -->|Provides context to| G[🤖 AI Assistant]
|
|
309
|
+
|
|
310
|
+
classDef default fill:#1f2937,stroke:#8b5cf6,stroke-width:2px,color:#fff;
|
|
311
|
+
classDef db fill:#0f172a,stroke:#3b82f6,stroke-width:2px,color:#fff;
|
|
312
|
+
classDef ai fill:#312e81,stroke:#a855f7,stroke-width:2px,color:#fff;
|
|
313
|
+
|
|
314
|
+
D:::db
|
|
315
|
+
G:::ai
|
|
316
|
+
```
|
|
317
|
+
|
|
274
318
|
---
|
|
275
319
|
|
|
276
320
|
## 🏗️ Architecture & Workflow
|
|
@@ -309,10 +353,12 @@ CodeGraphContext provides comprehensive parsing and analysis for the following l
|
|
|
309
353
|
| 🎨 | **Kotlin** | 🎯 | **Dart** | 🐪 | **Perl** |
|
|
310
354
|
| 🌙 | **Lua** | 🚀 | **Scala** | λ | **Haskell** |
|
|
311
355
|
| 💧 | **Elixir** | 📜 | **Emacs Lisp (elisp)** | 🌐 | **HTML** |
|
|
312
|
-
| 🎨 | **CSS** | ⚛️ | **TSX** | | |
|
|
356
|
+
| 🎨 | **CSS** | ⚛️ | **TSX** | ⛓️ | **Solidity** |
|
|
313
357
|
|
|
314
358
|
Each language parser extracts functions, classes, methods, parameters, inheritance relationships, function calls, and imports to build a comprehensive code graph.
|
|
315
359
|
|
|
360
|
+
**Solidity notes:** `.sol` uses Tree-sitter via `tree-sitter-language-pack` (no SCIP). Supports Foundry remappings, modifier invocations, `using Lib for T`, and `emit` / custom-error `revert` as CALLS. See `docs/docs/contributing_languages.md` § Solidity.
|
|
361
|
+
|
|
316
362
|
---
|
|
317
363
|
|
|
318
364
|
## Database Options
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- 🇺🇦 [Українська](docs/translations/README.uk.md)
|
|
10
10
|
- 🇷🇺 [Русский](docs/translations/README.ru-RU.md)
|
|
11
11
|
- 🇯🇵 [日本語](docs/translations/README.ja.md)
|
|
12
|
+
- 🇮🇳 [தமிழ்](docs/translations/README.ta.md)
|
|
12
13
|
- 🇪🇸 Español (Soon)
|
|
13
14
|
|
|
14
15
|
🌍 **Help translate CodeGraphContext to your language by raising an issue & PR on [GitHub Issues](https://github.com/CodeGraphContext/CodeGraphContext/issues)!**
|
|
@@ -173,6 +174,49 @@ flowchart LR
|
|
|
173
174
|
- **Flexible Database Backend:** FalkorDB Lite (Default), KuzuDB, LadybugDB, FalkorDB Remote, Nornic DB, or Neo4j (all platforms via Docker/native).
|
|
174
175
|
|
|
175
176
|
|
|
177
|
+
---
|
|
178
|
+
## Architecture Overview
|
|
179
|
+
|
|
180
|
+
CodeGraphContext transforms source code into a queryable knowledge graph that can be explored through the CLI or AI assistants via MCP.
|
|
181
|
+
|
|
182
|
+
```mermaid
|
|
183
|
+
flowchart TD
|
|
184
|
+
A[Code Repository] --> B[Tree-sitter / SCIP Indexing]
|
|
185
|
+
B --> C[Knowledge Graph]
|
|
186
|
+
C --> D[Graph Database]
|
|
187
|
+
D --> E[CLI Toolkit]
|
|
188
|
+
D --> F[MCP Server]
|
|
189
|
+
F --> G[AI Assistant]
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Workflow
|
|
193
|
+
|
|
194
|
+
1. Source code is parsed using Tree-sitter or SCIP indexers.
|
|
195
|
+
2. Relationships between functions, classes, imports, and calls are extracted.
|
|
196
|
+
3. A knowledge graph is generated and stored in a graph database.
|
|
197
|
+
4. Users can query the graph through the CLI or AI assistants using MCP.
|
|
198
|
+
|
|
199
|
+
## 🏗️ Architecture & Workflow
|
|
200
|
+
|
|
201
|
+
CodeGraphContext parses your source code and builds a comprehensive knowledge graph. This graph can be queried directly via the CLI toolkit or exposed to AI assistants through the MCP server.
|
|
202
|
+
|
|
203
|
+
```mermaid
|
|
204
|
+
flowchart TD
|
|
205
|
+
A[Code Repository] -->|Parsed by| B[Tree-sitter / SCIP Indexing]
|
|
206
|
+
B -->|Generates| C[Knowledge Graph]
|
|
207
|
+
C -->|Stored in| D[(Graph Database)]
|
|
208
|
+
D -->|Queried via| E[CLI Toolkit]
|
|
209
|
+
D -->|Served by| F[MCP Server]
|
|
210
|
+
F -->|Provides context to| G[🤖 AI Assistant]
|
|
211
|
+
|
|
212
|
+
classDef default fill:#1f2937,stroke:#8b5cf6,stroke-width:2px,color:#fff;
|
|
213
|
+
classDef db fill:#0f172a,stroke:#3b82f6,stroke-width:2px,color:#fff;
|
|
214
|
+
classDef ai fill:#312e81,stroke:#a855f7,stroke-width:2px,color:#fff;
|
|
215
|
+
|
|
216
|
+
D:::db
|
|
217
|
+
G:::ai
|
|
218
|
+
```
|
|
219
|
+
|
|
176
220
|
---
|
|
177
221
|
|
|
178
222
|
## 🏗️ Architecture & Workflow
|
|
@@ -211,10 +255,12 @@ CodeGraphContext provides comprehensive parsing and analysis for the following l
|
|
|
211
255
|
| 🎨 | **Kotlin** | 🎯 | **Dart** | 🐪 | **Perl** |
|
|
212
256
|
| 🌙 | **Lua** | 🚀 | **Scala** | λ | **Haskell** |
|
|
213
257
|
| 💧 | **Elixir** | 📜 | **Emacs Lisp (elisp)** | 🌐 | **HTML** |
|
|
214
|
-
| 🎨 | **CSS** | ⚛️ | **TSX** | | |
|
|
258
|
+
| 🎨 | **CSS** | ⚛️ | **TSX** | ⛓️ | **Solidity** |
|
|
215
259
|
|
|
216
260
|
Each language parser extracts functions, classes, methods, parameters, inheritance relationships, function calls, and imports to build a comprehensive code graph.
|
|
217
261
|
|
|
262
|
+
**Solidity notes:** `.sol` uses Tree-sitter via `tree-sitter-language-pack` (no SCIP). Supports Foundry remappings, modifier invocations, `using Lib for T`, and `emit` / custom-error `revert` as CALLS. See `docs/docs/contributing_languages.md` § Solidity.
|
|
263
|
+
|
|
218
264
|
---
|
|
219
265
|
|
|
220
266
|
## Database Options
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "codegraphcontext"
|
|
3
|
-
version = "0.5.
|
|
3
|
+
version = "0.5.4"
|
|
4
4
|
description = "An MCP server that indexes local code into a graph database to provide context to AI assistants."
|
|
5
5
|
authors = [{ name = "Shashank Shekhar Singh", email = "shashankshekharsingh1205@gmail.com" }]
|
|
6
6
|
readme = "README.md"
|
|
@@ -58,9 +58,28 @@ dependencies = [
|
|
|
58
58
|
"falkordblite>=0.7,<0.10; sys_platform != 'win32' and python_version >= '3.12'",
|
|
59
59
|
"requests>=2.28.0",
|
|
60
60
|
"protobuf>=3.20,<3.21",
|
|
61
|
-
|
|
61
|
+
# ------------------------------------------------------------------
|
|
62
|
+
# KùzuDB was archived upstream on 2025-10-10; 0.11.3 is the final
|
|
63
|
+
# release and its wheel matrix stops at cp313 for macOS and Windows.
|
|
64
|
+
# Only Linux (manylinux x86_64 / aarch64) got cp314 wheels. Without a
|
|
65
|
+
# marker, `pip install codegraphcontext` on macOS/Windows + Python 3.14
|
|
66
|
+
# falls back to the kuzu sdist and tries a full C++/CMake source build,
|
|
67
|
+
# which fails and takes the whole install down with it.
|
|
68
|
+
#
|
|
69
|
+
# Keep kuzu where a wheel actually exists; elsewhere the backend is
|
|
70
|
+
# simply absent and `database_kuzu` reports its install hint at runtime.
|
|
71
|
+
# LadybugDB (the maintained Kùzu fork, see issue #852) publishes cp314
|
|
72
|
+
# wheels for all three platforms and remains the unconditional default.
|
|
73
|
+
# ------------------------------------------------------------------
|
|
74
|
+
"kuzu; python_version < '3.14' or sys_platform == 'linux'",
|
|
62
75
|
"ladybug; sys_platform == 'win32' or (sys_platform != 'win32' and python_version >= '3.10')",
|
|
63
|
-
|
|
76
|
+
# Cap below 2.0: the low-level `mcp.server.Server` dropped its `list_tools`
|
|
77
|
+
# and `call_tool` decorators in 2.0.0, which api/mcp_sse.py registers its
|
|
78
|
+
# handlers with. With an unbounded pin, CI resolved 2.0.0 on release day and
|
|
79
|
+
# every job failed at import with
|
|
80
|
+
# "AttributeError: 'Server' object has no attribute 'list_tools'".
|
|
81
|
+
# Lift this once mcp_sse.py is ported to the 2.x server API.
|
|
82
|
+
"mcp>=1.0.0,<2",
|
|
64
83
|
"fastapi>=0.100.0",
|
|
65
84
|
"uvicorn>=0.22.0"
|
|
66
85
|
]
|
|
@@ -85,7 +104,9 @@ falkordb-remote = [
|
|
|
85
104
|
"redis>=5,<6",
|
|
86
105
|
]
|
|
87
106
|
kuzu = [
|
|
88
|
-
|
|
107
|
+
# Same wheel-availability marker as the core dependency above: no
|
|
108
|
+
# cp314 wheels exist for macOS/Windows and the sdist cannot be built.
|
|
109
|
+
"kuzu; python_version < '3.14' or sys_platform == 'linux'",
|
|
89
110
|
]
|
|
90
111
|
ladybug = [
|
|
91
112
|
"ladybug; sys_platform == 'win32' or (sys_platform != 'win32' and python_version >= '3.10')",
|
|
@@ -112,8 +133,8 @@ datasources = [
|
|
|
112
133
|
]
|
|
113
134
|
|
|
114
135
|
[project.urls]
|
|
115
|
-
"Homepage" = "https://github.com/
|
|
116
|
-
"Bug Tracker" = "https://github.com/
|
|
136
|
+
"Homepage" = "https://github.com/CodeGraphContext/CodeGraphContext"
|
|
137
|
+
"Bug Tracker" = "https://github.com/CodeGraphContext/CodeGraphContext/issues"
|
|
117
138
|
|
|
118
139
|
[project.scripts]
|
|
119
140
|
cgc = "codegraphcontext.cli.main:app"
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
# src/codegraphcontext/api/app.py
|
|
2
2
|
import os
|
|
3
|
-
from fastapi import FastAPI
|
|
3
|
+
from fastapi import Depends, FastAPI
|
|
4
4
|
from fastapi.responses import HTMLResponse
|
|
5
5
|
from fastapi.middleware.cors import CORSMiddleware
|
|
6
6
|
from .router import router
|
|
7
|
+
from .auth import log_auth_status, require_api_key
|
|
7
8
|
from .mcp_sse import handle_sse, handle_messages
|
|
8
9
|
|
|
9
10
|
def create_app() -> FastAPI:
|
|
11
|
+
# Log whether API-key auth is active. Emits a prominent security warning
|
|
12
|
+
# when the gateway is running unauthenticated (CGC_API_KEY unset).
|
|
13
|
+
log_auth_status()
|
|
14
|
+
|
|
10
15
|
app = FastAPI(
|
|
11
16
|
title="CodeGraphContext Gateway",
|
|
12
17
|
description="HTTP API gateway for CodeGraphContext MCP server. Enables integration with ChatGPT Actions, Claude, and web frontends.",
|
|
@@ -32,9 +37,23 @@ def create_app() -> FastAPI:
|
|
|
32
37
|
"""Liveness probe for load balancers and k8s."""
|
|
33
38
|
return {"status": "ok"}
|
|
34
39
|
|
|
35
|
-
# MCP-over-SSE Endpoints
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
# MCP-over-SSE Endpoints. These dispatch to the same tools as the REST
|
|
41
|
+
# router (execute_cypher_query, add_code_to_graph, delete_repository), so
|
|
42
|
+
# they need the same API-key dependency the router applies — without it,
|
|
43
|
+
# setting CGC_API_KEY left the SSE transport as an unauthenticated path to
|
|
44
|
+
# every tool.
|
|
45
|
+
app.add_api_route(
|
|
46
|
+
"/api/v1/mcp/sse",
|
|
47
|
+
handle_sse,
|
|
48
|
+
methods=["GET"],
|
|
49
|
+
dependencies=[Depends(require_api_key)],
|
|
50
|
+
)
|
|
51
|
+
app.add_api_route(
|
|
52
|
+
"/api/v1/mcp/messages",
|
|
53
|
+
handle_messages,
|
|
54
|
+
methods=["POST"],
|
|
55
|
+
dependencies=[Depends(require_api_key)],
|
|
56
|
+
)
|
|
38
57
|
|
|
39
58
|
@app.get("/", response_class=HTMLResponse)
|
|
40
59
|
async def root():
|
|
@@ -61,7 +80,7 @@ def create_app() -> FastAPI:
|
|
|
61
80
|
<a href="/docs" class="btn">View API Docs</a>
|
|
62
81
|
<div class="links">
|
|
63
82
|
<a href="/openapi.json">OpenAPI Spec</a>
|
|
64
|
-
<a href="https://github.com/
|
|
83
|
+
<a href="https://github.com/CodeGraphContext/CodeGraphContext" target="_blank">GitHub</a>
|
|
65
84
|
</div>
|
|
66
85
|
</div>
|
|
67
86
|
</body>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# src/codegraphcontext/api/auth.py
|
|
2
|
+
"""Optional API-key authentication for the CodeGraphContext HTTP API.
|
|
3
|
+
|
|
4
|
+
Backward-compatible and opt-in:
|
|
5
|
+
|
|
6
|
+
* When **no** key is configured, the API behaves exactly as it did before
|
|
7
|
+
(every endpoint is unauthenticated) but a prominent security warning is
|
|
8
|
+
logged at startup so operators know the gateway is wide open.
|
|
9
|
+
* When a key **is** configured (via the ``CGC_API_KEY`` environment variable
|
|
10
|
+
or the standard config mechanism), every protected router endpoint requires
|
|
11
|
+
it, supplied as either ``Authorization: Bearer <key>`` or ``X-API-Key: <key>``.
|
|
12
|
+
Missing/incorrect keys receive an HTTP ``401``.
|
|
13
|
+
|
|
14
|
+
The comparison uses :func:`secrets.compare_digest` to avoid timing side
|
|
15
|
+
channels.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
import logging
|
|
19
|
+
import os
|
|
20
|
+
import secrets
|
|
21
|
+
from typing import Optional
|
|
22
|
+
|
|
23
|
+
from fastapi import Header, HTTPException
|
|
24
|
+
|
|
25
|
+
logger = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
# Config/env key that holds the API key. Reused as the config_manager key so
|
|
28
|
+
# ``cgc config set CGC_API_KEY <value>`` works as well.
|
|
29
|
+
API_KEY_ENV = "CGC_API_KEY"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def get_configured_api_key() -> Optional[str]:
|
|
33
|
+
"""Return the configured API key, or ``None`` when auth is disabled.
|
|
34
|
+
|
|
35
|
+
Resolution order (highest priority first):
|
|
36
|
+
|
|
37
|
+
1. The ``CGC_API_KEY`` environment variable (read directly so auth works
|
|
38
|
+
even when no config file is present).
|
|
39
|
+
2. The value stored via the existing config mechanism
|
|
40
|
+
(:func:`codegraphcontext.cli.config_manager.get_config_value`).
|
|
41
|
+
|
|
42
|
+
Empty / whitespace-only values are treated as "not configured".
|
|
43
|
+
"""
|
|
44
|
+
env_val = os.getenv(API_KEY_ENV)
|
|
45
|
+
if env_val and env_val.strip():
|
|
46
|
+
return env_val.strip()
|
|
47
|
+
|
|
48
|
+
# Fall back to the existing config mechanism (global/local .env, defaults).
|
|
49
|
+
try:
|
|
50
|
+
from codegraphcontext.cli.config_manager import get_config_value
|
|
51
|
+
|
|
52
|
+
cfg_val = get_config_value(API_KEY_ENV)
|
|
53
|
+
if cfg_val and cfg_val.strip():
|
|
54
|
+
return cfg_val.strip()
|
|
55
|
+
except Exception: # pragma: no cover - config lookup is best-effort here
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
return None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _extract_provided_key(
|
|
62
|
+
authorization: Optional[str], x_api_key: Optional[str]
|
|
63
|
+
) -> Optional[str]:
|
|
64
|
+
"""Pull the caller-supplied key from the Authorization or X-API-Key header."""
|
|
65
|
+
if authorization:
|
|
66
|
+
value = authorization.strip()
|
|
67
|
+
if value.lower().startswith("bearer "):
|
|
68
|
+
return value[len("bearer ") :].strip()
|
|
69
|
+
# Accept a bare token in the Authorization header as a convenience.
|
|
70
|
+
return value or None
|
|
71
|
+
if x_api_key and x_api_key.strip():
|
|
72
|
+
return x_api_key.strip()
|
|
73
|
+
return None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _keys_match(provided: str, configured: str) -> bool:
|
|
77
|
+
"""Constant-time comparison that never raises on non-ASCII input."""
|
|
78
|
+
try:
|
|
79
|
+
return secrets.compare_digest(
|
|
80
|
+
provided.encode("utf-8"), configured.encode("utf-8")
|
|
81
|
+
)
|
|
82
|
+
except (TypeError, AttributeError):
|
|
83
|
+
return False
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
async def require_api_key(
|
|
87
|
+
authorization: Optional[str] = Header(default=None),
|
|
88
|
+
x_api_key: Optional[str] = Header(default=None, alias="X-API-Key"),
|
|
89
|
+
) -> None:
|
|
90
|
+
"""FastAPI dependency that enforces the API key when one is configured.
|
|
91
|
+
|
|
92
|
+
No-op (backward compatible) when no key is set; otherwise requires a valid
|
|
93
|
+
key via ``Authorization: Bearer <key>`` or ``X-API-Key: <key>``, returning
|
|
94
|
+
HTTP ``401`` on a missing or incorrect key.
|
|
95
|
+
"""
|
|
96
|
+
configured = get_configured_api_key()
|
|
97
|
+
if not configured:
|
|
98
|
+
# Auth disabled -> preserve the pre-existing unauthenticated behavior.
|
|
99
|
+
return
|
|
100
|
+
|
|
101
|
+
provided = _extract_provided_key(authorization, x_api_key)
|
|
102
|
+
if not provided or not _keys_match(provided, configured):
|
|
103
|
+
raise HTTPException(
|
|
104
|
+
status_code=401,
|
|
105
|
+
detail="Invalid or missing API key",
|
|
106
|
+
headers={"WWW-Authenticate": "Bearer"},
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def log_auth_status() -> None:
|
|
111
|
+
"""Log the authentication status at app startup.
|
|
112
|
+
|
|
113
|
+
Emits a prominent WARNING when the API is unauthenticated so the insecure
|
|
114
|
+
default is impossible to miss in logs.
|
|
115
|
+
"""
|
|
116
|
+
if get_configured_api_key():
|
|
117
|
+
logger.info("API key authentication is ENABLED (CGC_API_KEY is set).")
|
|
118
|
+
else:
|
|
119
|
+
logger.warning(
|
|
120
|
+
"⚠️ CodeGraphContext API is running WITHOUT authentication. "
|
|
121
|
+
"Anyone who can reach this server can index code, run Cypher queries "
|
|
122
|
+
"and call tools. Set CGC_API_KEY to require a key."
|
|
123
|
+
)
|
|
@@ -48,11 +48,41 @@ async def handle_call_tool(name: str, arguments: dict | None) -> list[TextConten
|
|
|
48
48
|
# Create the SSE transport.
|
|
49
49
|
sse = SseServerTransport("/api/v1/mcp/messages")
|
|
50
50
|
|
|
51
|
+
|
|
52
|
+
class _AlreadySentResponse(Response):
|
|
53
|
+
"""Placeholder for a response the MCP transport wrote itself.
|
|
54
|
+
|
|
55
|
+
Both handlers below hand the raw ASGI ``send`` to the SDK, which emits the
|
|
56
|
+
complete response. FastAPI still does ``await endpoint(request)`` followed
|
|
57
|
+
by ``await response(...)``, so returning ``None`` raises ``TypeError:
|
|
58
|
+
'NoneType' object is not callable`` and returning a real ``Response`` starts
|
|
59
|
+
a second response on a finished ASGI cycle. This satisfies FastAPI while
|
|
60
|
+
putting nothing on the wire.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
async def __call__(self, scope, receive, send) -> None:
|
|
64
|
+
return
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class _SendTracker:
|
|
68
|
+
"""ASGI ``send`` wrapper that records whether a response was started."""
|
|
69
|
+
|
|
70
|
+
def __init__(self, send):
|
|
71
|
+
self._send = send
|
|
72
|
+
self.response_started = False
|
|
73
|
+
|
|
74
|
+
async def __call__(self, message) -> None:
|
|
75
|
+
if message.get("type") == "http.response.start":
|
|
76
|
+
self.response_started = True
|
|
77
|
+
await self._send(message)
|
|
78
|
+
|
|
79
|
+
|
|
51
80
|
async def handle_sse(request: Request):
|
|
52
81
|
"""Entry point for the SSE connection."""
|
|
53
82
|
logger.info("SSE client connected")
|
|
83
|
+
sender = _SendTracker(request._send)
|
|
54
84
|
try:
|
|
55
|
-
async with sse.connect_sse(request.scope, request.receive,
|
|
85
|
+
async with sse.connect_sse(request.scope, request.receive, sender) as (read_stream, write_stream):
|
|
56
86
|
await mcp_server.run(
|
|
57
87
|
read_stream,
|
|
58
88
|
write_stream,
|
|
@@ -70,6 +100,10 @@ async def handle_sse(request: Request):
|
|
|
70
100
|
logger.debug("SSE connection closed: %s", type(exc).__name__)
|
|
71
101
|
finally:
|
|
72
102
|
logger.info("SSE client disconnected — handler exited, resources freed")
|
|
103
|
+
if sender.response_started:
|
|
104
|
+
return _AlreadySentResponse()
|
|
105
|
+
# connect_sse bailed out before writing anything (e.g. rejected origin).
|
|
106
|
+
return Response(status_code=500, content="SSE connection could not be established")
|
|
73
107
|
|
|
74
108
|
|
|
75
109
|
async def handle_messages(request: Request):
|
|
@@ -99,7 +133,20 @@ async def handle_messages(request: Request):
|
|
|
99
133
|
media_type="application/json"
|
|
100
134
|
)
|
|
101
135
|
|
|
136
|
+
# `handle_post_message` builds its own Request and awaits `.body()` again.
|
|
137
|
+
# Starlette caches a body on the Request instance, not in the scope, so
|
|
138
|
+
# handing it the raw `receive` would make it wait for a body that has
|
|
139
|
+
# already been drained above — the POST hangs until the client gives up and
|
|
140
|
+
# the message never reaches the session. Replay the buffered bytes instead.
|
|
141
|
+
async def replay_receive() -> dict:
|
|
142
|
+
return {"type": "http.request", "body": raw_body, "more_body": False}
|
|
143
|
+
|
|
144
|
+
sender = _SendTracker(request._send)
|
|
102
145
|
try:
|
|
103
|
-
await sse.handle_post_message(request.scope,
|
|
146
|
+
await sse.handle_post_message(request.scope, replay_receive, sender)
|
|
104
147
|
except Exception as exc:
|
|
105
148
|
logger.debug("Message handler closed: %s", type(exc).__name__)
|
|
149
|
+
|
|
150
|
+
if sender.response_started:
|
|
151
|
+
return _AlreadySentResponse()
|
|
152
|
+
return Response(status_code=202, content="Accepted")
|
|
@@ -5,17 +5,21 @@ from typing import Dict, Any, List
|
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
|
|
7
7
|
from .schemas import (
|
|
8
|
-
IndexRequest,
|
|
9
|
-
QueryRequest,
|
|
10
|
-
SearchRequest,
|
|
11
|
-
ToolCallRequest,
|
|
8
|
+
IndexRequest,
|
|
9
|
+
QueryRequest,
|
|
10
|
+
SearchRequest,
|
|
11
|
+
ToolCallRequest,
|
|
12
12
|
ApiResponse
|
|
13
13
|
)
|
|
14
|
+
from .auth import require_api_key
|
|
14
15
|
from codegraphcontext.server import MCPServer
|
|
15
16
|
|
|
16
17
|
import socket
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
# Optional API-key auth is enforced on every route below via require_api_key.
|
|
20
|
+
# It is a no-op (backward compatible) unless CGC_API_KEY is configured, in
|
|
21
|
+
# which case each request must supply the key. See codegraphcontext.api.auth.
|
|
22
|
+
router = APIRouter(dependencies=[Depends(require_api_key)])
|
|
19
23
|
|
|
20
24
|
# Global server instance (initialized on startup)
|
|
21
25
|
_server_instance: MCPServer = None
|