codegraphcontext 0.1.7__tar.gz → 0.1.9__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.1.7 → codegraphcontext-0.1.9}/LICENSE +0 -0
- {codegraphcontext-0.1.7/src/codegraphcontext.egg-info → codegraphcontext-0.1.9}/PKG-INFO +61 -4
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/README.md +60 -3
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/pyproject.toml +2 -1
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/__init__.py +0 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/__main__.py +0 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/cli/__init__.py +0 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/cli/main.py +57 -9
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/cli/setup_wizard.py +13 -2
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/core/__init__.py +0 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/core/database.py +0 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/core/jobs.py +0 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/core/watcher.py +0 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/prompts.py +0 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/server.py +17 -22
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/tools/__init__.py +0 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/tools/code_finder.py +150 -18
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/tools/graph_builder.py +179 -31
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/tools/import_extractor.py +13 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext/tools/system.py +0 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9/src/codegraphcontext.egg-info}/PKG-INFO +61 -4
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext.egg-info/SOURCES.txt +5 -1
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext.egg-info/dependency_links.txt +0 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext.egg-info/entry_points.txt +1 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext.egg-info/requires.txt +0 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/src/codegraphcontext.egg-info/top_level.txt +0 -0
- codegraphcontext-0.1.9/tests/test_cgc_integration.py +30 -0
- codegraphcontext-0.1.9/tests/test_imports.py +185 -0
- codegraphcontext-0.1.9/tests/test_jsonrpc.py +113 -0
- codegraphcontext-0.1.9/tests/test_tools.py +373 -0
- {codegraphcontext-0.1.7 → codegraphcontext-0.1.9}/setup.cfg +0 -0
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codegraphcontext
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.9
|
|
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
|
|
@@ -52,10 +52,18 @@ Dynamic: license-file
|
|
|
52
52
|
|
|
53
53
|
# CodeGraphContext
|
|
54
54
|
[](https://github.com/Shashankss1205/CodeGraphContext/actions/workflows/test.yml)
|
|
55
|
-
|
|
55
|
+
[](https://pypi.org/project/codegraphcontext/)
|
|
56
|
+
[](https://pypi.org/project/codegraphcontext/)
|
|
57
|
+
[](https://github.com/Shashankss1205/CodeGraphContext/stargazers)
|
|
58
|
+
[](LICENSE)
|
|
56
59
|
|
|
57
60
|
An MCP server that indexes local code into a graph database to provide context to AI assistants.
|
|
58
61
|
|
|
62
|
+
## Project Details
|
|
63
|
+
- **Version:** 0.1.8
|
|
64
|
+
- **Authors:** Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
|
|
65
|
+
- **License:** MIT License (See [LICENSE](LICENSE) for details)
|
|
66
|
+
|
|
59
67
|
## Features
|
|
60
68
|
|
|
61
69
|
- **Code Indexing:** Analyzes Python code and builds a knowledge graph of its components.
|
|
@@ -63,12 +71,33 @@ An MCP server that indexes local code into a graph database to provide context t
|
|
|
63
71
|
- **Live Updates:** Watches local files for changes and automatically updates the graph.
|
|
64
72
|
- **Interactive Setup:** A user-friendly command-line wizard for easy setup.
|
|
65
73
|
|
|
74
|
+
## Used By
|
|
75
|
+
|
|
76
|
+
CodeGraphContext is already being explored by developers and projects for:
|
|
77
|
+
|
|
78
|
+
- **Static code analysis in AI assistants**
|
|
79
|
+
- **Graph-based visualization of Python projects**
|
|
80
|
+
- **Dead code and complexity detection**
|
|
81
|
+
|
|
82
|
+
If you’re using CodeGraphContext in your project, feel free to open a PR and add it here! 🚀
|
|
83
|
+
|
|
84
|
+
## Dependencies
|
|
85
|
+
|
|
86
|
+
- `neo4j>=5.15.0`
|
|
87
|
+
- `watchdog>=3.0.0`
|
|
88
|
+
- `requests>=2.31.0`
|
|
89
|
+
- `stdlibs>=2023.11.18`
|
|
90
|
+
- `typer[all]>=0.9.0`
|
|
91
|
+
- `rich>=13.7.0`
|
|
92
|
+
- `inquirerpy>=0.3.4`
|
|
93
|
+
- `python-dotenv>=1.0.0`
|
|
94
|
+
|
|
66
95
|
## Getting Started
|
|
67
96
|
|
|
68
97
|
1. **Install:** `pip install codegraphcontext`
|
|
69
98
|
2. **Setup:** `cgc setup`
|
|
70
99
|
3. **Start:** `cgc start`
|
|
71
|
-
4. **Index Code:** `cgc tool add-code-to-graph '{"path": "/path/to/your/project"}'`
|
|
100
|
+
4. **Index Code:** `cgc tool add-code-to-graph '{"path": "/path/to/your/project"}'` (Under active development)
|
|
72
101
|
|
|
73
102
|
## MCP Client Configuration
|
|
74
103
|
|
|
@@ -98,7 +127,11 @@ Add the following to your MCP client's configuration:
|
|
|
98
127
|
"analyze_code_relationships",
|
|
99
128
|
"watch_directory",
|
|
100
129
|
"find_dead_code",
|
|
101
|
-
"execute_cypher_query"
|
|
130
|
+
"execute_cypher_query",
|
|
131
|
+
"calculate_cyclomatic_complexity",
|
|
132
|
+
"find_most_complex_functions",
|
|
133
|
+
"list_indexed_repositories",
|
|
134
|
+
"delete_repository"
|
|
102
135
|
],
|
|
103
136
|
"disabled": false
|
|
104
137
|
},
|
|
@@ -149,5 +182,29 @@ Once the server is running, you can interact with it through your AI assistant u
|
|
|
149
182
|
- "Which files import the `requests` library?"
|
|
150
183
|
- "Find all implementations of the `render` method."
|
|
151
184
|
|
|
185
|
+
- **Advanced Call Chain and Dependency Tracking (Spanning Hundreds of Files):**
|
|
186
|
+
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:
|
|
187
|
+
- **Impact Analysis:** Understand the full ripple effect of a change to a core function.
|
|
188
|
+
- **Debugging:** Trace the path of execution from an entry point to a specific bug.
|
|
189
|
+
- **Code Comprehension:** Grasp how different parts of a large system interact.
|
|
190
|
+
|
|
191
|
+
- "Show me the full call chain from the `main` function to `process_data`."
|
|
192
|
+
- "Find all functions that directly or indirectly call `validate_input`."
|
|
193
|
+
- "What are all the functions that `initialize_system` eventually calls?"
|
|
194
|
+
- "Trace the dependencies of the `DatabaseManager` module."
|
|
195
|
+
|
|
152
196
|
- **Code Quality and Maintenance:**
|
|
153
197
|
- "Is there any dead or unused code in this project?"
|
|
198
|
+
- "Calculate the cyclomatic complexity of the `process_data` function in `src/utils.py`."
|
|
199
|
+
- "Find the 5 most complex functions in the codebase."
|
|
200
|
+
|
|
201
|
+
- **Repository Management:**
|
|
202
|
+
- "List all currently indexed repositories."
|
|
203
|
+
- "Delete the indexed repository at `/path/to/old-project`."
|
|
204
|
+
|
|
205
|
+
## Contributing
|
|
206
|
+
|
|
207
|
+
Contributions are welcome! 🎉
|
|
208
|
+
If you have ideas for new features, integrations, or improvements, open an [issue](https://github.com/Shashankss1205/CodeGraphContext/issues) or submit a PR.
|
|
209
|
+
|
|
210
|
+
Join discussions and help shape the future of CodeGraphContext.
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# CodeGraphContext
|
|
2
2
|
[](https://github.com/Shashankss1205/CodeGraphContext/actions/workflows/test.yml)
|
|
3
|
-
|
|
3
|
+
[](https://pypi.org/project/codegraphcontext/)
|
|
4
|
+
[](https://pypi.org/project/codegraphcontext/)
|
|
5
|
+
[](https://github.com/Shashankss1205/CodeGraphContext/stargazers)
|
|
6
|
+
[](LICENSE)
|
|
4
7
|
|
|
5
8
|
An MCP server that indexes local code into a graph database to provide context to AI assistants.
|
|
6
9
|
|
|
10
|
+
## Project Details
|
|
11
|
+
- **Version:** 0.1.8
|
|
12
|
+
- **Authors:** Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
|
|
13
|
+
- **License:** MIT License (See [LICENSE](LICENSE) for details)
|
|
14
|
+
|
|
7
15
|
## Features
|
|
8
16
|
|
|
9
17
|
- **Code Indexing:** Analyzes Python code and builds a knowledge graph of its components.
|
|
@@ -11,12 +19,33 @@ An MCP server that indexes local code into a graph database to provide context t
|
|
|
11
19
|
- **Live Updates:** Watches local files for changes and automatically updates the graph.
|
|
12
20
|
- **Interactive Setup:** A user-friendly command-line wizard for easy setup.
|
|
13
21
|
|
|
22
|
+
## Used By
|
|
23
|
+
|
|
24
|
+
CodeGraphContext is already being explored by developers and projects for:
|
|
25
|
+
|
|
26
|
+
- **Static code analysis in AI assistants**
|
|
27
|
+
- **Graph-based visualization of Python projects**
|
|
28
|
+
- **Dead code and complexity detection**
|
|
29
|
+
|
|
30
|
+
If you’re using CodeGraphContext in your project, feel free to open a PR and add it here! 🚀
|
|
31
|
+
|
|
32
|
+
## Dependencies
|
|
33
|
+
|
|
34
|
+
- `neo4j>=5.15.0`
|
|
35
|
+
- `watchdog>=3.0.0`
|
|
36
|
+
- `requests>=2.31.0`
|
|
37
|
+
- `stdlibs>=2023.11.18`
|
|
38
|
+
- `typer[all]>=0.9.0`
|
|
39
|
+
- `rich>=13.7.0`
|
|
40
|
+
- `inquirerpy>=0.3.4`
|
|
41
|
+
- `python-dotenv>=1.0.0`
|
|
42
|
+
|
|
14
43
|
## Getting Started
|
|
15
44
|
|
|
16
45
|
1. **Install:** `pip install codegraphcontext`
|
|
17
46
|
2. **Setup:** `cgc setup`
|
|
18
47
|
3. **Start:** `cgc start`
|
|
19
|
-
4. **Index Code:** `cgc tool add-code-to-graph '{"path": "/path/to/your/project"}'`
|
|
48
|
+
4. **Index Code:** `cgc tool add-code-to-graph '{"path": "/path/to/your/project"}'` (Under active development)
|
|
20
49
|
|
|
21
50
|
## MCP Client Configuration
|
|
22
51
|
|
|
@@ -46,7 +75,11 @@ Add the following to your MCP client's configuration:
|
|
|
46
75
|
"analyze_code_relationships",
|
|
47
76
|
"watch_directory",
|
|
48
77
|
"find_dead_code",
|
|
49
|
-
"execute_cypher_query"
|
|
78
|
+
"execute_cypher_query",
|
|
79
|
+
"calculate_cyclomatic_complexity",
|
|
80
|
+
"find_most_complex_functions",
|
|
81
|
+
"list_indexed_repositories",
|
|
82
|
+
"delete_repository"
|
|
50
83
|
],
|
|
51
84
|
"disabled": false
|
|
52
85
|
},
|
|
@@ -97,5 +130,29 @@ Once the server is running, you can interact with it through your AI assistant u
|
|
|
97
130
|
- "Which files import the `requests` library?"
|
|
98
131
|
- "Find all implementations of the `render` method."
|
|
99
132
|
|
|
133
|
+
- **Advanced Call Chain and Dependency Tracking (Spanning Hundreds of Files):**
|
|
134
|
+
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:
|
|
135
|
+
- **Impact Analysis:** Understand the full ripple effect of a change to a core function.
|
|
136
|
+
- **Debugging:** Trace the path of execution from an entry point to a specific bug.
|
|
137
|
+
- **Code Comprehension:** Grasp how different parts of a large system interact.
|
|
138
|
+
|
|
139
|
+
- "Show me the full call chain from the `main` function to `process_data`."
|
|
140
|
+
- "Find all functions that directly or indirectly call `validate_input`."
|
|
141
|
+
- "What are all the functions that `initialize_system` eventually calls?"
|
|
142
|
+
- "Trace the dependencies of the `DatabaseManager` module."
|
|
143
|
+
|
|
100
144
|
- **Code Quality and Maintenance:**
|
|
101
145
|
- "Is there any dead or unused code in this project?"
|
|
146
|
+
- "Calculate the cyclomatic complexity of the `process_data` function in `src/utils.py`."
|
|
147
|
+
- "Find the 5 most complex functions in the codebase."
|
|
148
|
+
|
|
149
|
+
- **Repository Management:**
|
|
150
|
+
- "List all currently indexed repositories."
|
|
151
|
+
- "Delete the indexed repository at `/path/to/old-project`."
|
|
152
|
+
|
|
153
|
+
## Contributing
|
|
154
|
+
|
|
155
|
+
Contributions are welcome! 🎉
|
|
156
|
+
If you have ideas for new features, integrations, or improvements, open an [issue](https://github.com/Shashankss1205/CodeGraphContext/issues) or submit a PR.
|
|
157
|
+
|
|
158
|
+
Join discussions and help shape the future of CodeGraphContext.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "codegraphcontext"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.9"
|
|
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"
|
|
@@ -31,6 +31,7 @@ dependencies = [
|
|
|
31
31
|
|
|
32
32
|
[project.scripts]
|
|
33
33
|
cgc = "codegraphcontext.cli.main:app"
|
|
34
|
+
codegraphcontext = "codegraphcontext.cli.main:app"
|
|
34
35
|
|
|
35
36
|
[project.optional-dependencies]
|
|
36
37
|
dev = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,6 +3,10 @@ import typer
|
|
|
3
3
|
from rich.console import Console
|
|
4
4
|
import asyncio
|
|
5
5
|
import logging
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from dotenv import load_dotenv, find_dotenv
|
|
6
10
|
from codegraphcontext.server import MCPServer
|
|
7
11
|
from .setup_wizard import run_setup_wizard
|
|
8
12
|
|
|
@@ -31,6 +35,44 @@ def start():
|
|
|
31
35
|
Start the CodeGraphContext MCP server.
|
|
32
36
|
"""
|
|
33
37
|
console.print("[bold green]Starting CodeGraphContext Server...[/bold green]")
|
|
38
|
+
|
|
39
|
+
# 1. Prefer loading environment variables from mcp.json in the current directory
|
|
40
|
+
mcp_file_path = Path.cwd() / "mcp.json"
|
|
41
|
+
if mcp_file_path.exists():
|
|
42
|
+
try:
|
|
43
|
+
with open(mcp_file_path, "r") as f:
|
|
44
|
+
mcp_config = json.load(f)
|
|
45
|
+
|
|
46
|
+
server_env = mcp_config.get("mcpServers", {}).get("CodeGraphContext", {}).get("env", {})
|
|
47
|
+
for key, value in server_env.items():
|
|
48
|
+
os.environ[key] = value
|
|
49
|
+
console.print("[green]Loaded Neo4j credentials from local mcp.json.[/green]")
|
|
50
|
+
except Exception as e:
|
|
51
|
+
console.print(f"[bold red]Error loading mcp.json:[/bold red] {e}")
|
|
52
|
+
console.print("[yellow]Attempting to start server without mcp.json environment variables.[/yellow]")
|
|
53
|
+
else:
|
|
54
|
+
# 2. If no local mcp.json, try to load from ~/.codegraphcontext/.env
|
|
55
|
+
global_env_path = Path.home() / ".codegraphcontext" / ".env"
|
|
56
|
+
if global_env_path.exists():
|
|
57
|
+
try:
|
|
58
|
+
load_dotenv(dotenv_path=global_env_path)
|
|
59
|
+
console.print(f"[green]Loaded Neo4j credentials from global .env file: {global_env_path}[/green]")
|
|
60
|
+
except Exception as e:
|
|
61
|
+
console.print(f"[bold red]Error loading global .env file from {global_env_path}:[/bold red] {e}")
|
|
62
|
+
console.print("[yellow]Attempting to start server without .env environment variables.[/yellow]")
|
|
63
|
+
else:
|
|
64
|
+
# Fallback: try to load from a .env file found by find_dotenv (searches up the tree)
|
|
65
|
+
try:
|
|
66
|
+
dotenv_path = find_dotenv(usecwd=True, raise_error_if_not_found=False)
|
|
67
|
+
if dotenv_path:
|
|
68
|
+
load_dotenv(dotenv_path)
|
|
69
|
+
console.print(f"[green]Loaded Neo4j credentials from global .env file: {dotenv_path}[/green]")
|
|
70
|
+
else:
|
|
71
|
+
console.print("[yellow]No local mcp.json or global .env file found. Attempting to start server without explicit Neo4j credentials.[/yellow]")
|
|
72
|
+
except Exception as e:
|
|
73
|
+
console.print(f"[bold red]Error loading global .env file:[/bold red] {e}")
|
|
74
|
+
console.print("[yellow]Attempting to start server without .env environment variables.[/yellow]")
|
|
75
|
+
|
|
34
76
|
server = None
|
|
35
77
|
loop = asyncio.new_event_loop()
|
|
36
78
|
asyncio.set_event_loop(loop)
|
|
@@ -79,15 +121,21 @@ def tool(
|
|
|
79
121
|
console.print(f"Calling tool [bold cyan]{name}[/bold cyan] with args: {args}")
|
|
80
122
|
console.print("[yellow]Note: This is a placeholder for direct tool invocation.[/yellow]")
|
|
81
123
|
|
|
124
|
+
@app.command()
|
|
125
|
+
def help(ctx: typer.Context):
|
|
126
|
+
"""Show this message and exit."""
|
|
127
|
+
root_ctx = ctx.parent or ctx
|
|
128
|
+
typer.echo(root_ctx.get_help())
|
|
129
|
+
|
|
82
130
|
|
|
83
|
-
@app.
|
|
84
|
-
def
|
|
131
|
+
@app.callback(invoke_without_command=True)
|
|
132
|
+
def main(ctx: typer.Context):
|
|
85
133
|
"""
|
|
86
|
-
|
|
134
|
+
CodeGraphContext: An MCP server for AI-powered code analysis.
|
|
87
135
|
"""
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
console.print(
|
|
93
|
-
|
|
136
|
+
if ctx.invoked_subcommand is None:
|
|
137
|
+
console.print("[bold green]👋 Welcome to CodeGraphContext (cgc)![/bold green]\n")
|
|
138
|
+
console.print("👉 Run [cyan]cgc setup[/cyan] to configure the server and database.")
|
|
139
|
+
console.print("👉 Run [cyan]cgc start[/cyan] to launch the server.")
|
|
140
|
+
console.print("👉 Run [cyan]cgc help[/cyan] to see all available commands.\n")
|
|
141
|
+
console.print("👉 Running [green]codegraphcontext [white]works the same as using [green]cgc")
|
|
@@ -30,7 +30,7 @@ def _generate_mcp_json(creds):
|
|
|
30
30
|
"args": args,
|
|
31
31
|
"env": {
|
|
32
32
|
"NEO4J_URI": creds.get("uri", ""),
|
|
33
|
-
"
|
|
33
|
+
"NEO4J_USERNAME": creds.get("username", "neo4j"),
|
|
34
34
|
"NEO4J_PASSWORD": creds.get("password", "")
|
|
35
35
|
},
|
|
36
36
|
"tools": {
|
|
@@ -60,6 +60,16 @@ def _generate_mcp_json(creds):
|
|
|
60
60
|
json.dump(mcp_config, f, indent=2)
|
|
61
61
|
console.print(f"\n[cyan]For your convenience, the configuration has also been saved to: {mcp_file}[/cyan]")
|
|
62
62
|
|
|
63
|
+
# Also save to a .env file for convenience
|
|
64
|
+
env_file = Path.home() / ".codegraphcontext" / ".env"
|
|
65
|
+
env_file.parent.mkdir(parents=True, exist_ok=True)
|
|
66
|
+
with open(env_file, "w") as f:
|
|
67
|
+
f.write(f"NEO4J_URI={creds.get('uri', '')}\n")
|
|
68
|
+
f.write(f"NEO4J_USERNAME={creds.get('username', 'neo4j')}\n")
|
|
69
|
+
f.write(f"NEO4J_PASSWORD={creds.get('password', '')}\n")
|
|
70
|
+
|
|
71
|
+
console.print(f"[cyan]Neo4j credentials also saved to: {env_file}[/cyan]")
|
|
72
|
+
|
|
63
73
|
|
|
64
74
|
def get_project_root() -> Path:
|
|
65
75
|
"""Always return the directory where the user runs `cgc` (CWD)."""
|
|
@@ -136,6 +146,7 @@ def find_latest_neo4j_creds_file():
|
|
|
136
146
|
def setup_hosted_db():
|
|
137
147
|
"""Guides user to configure a remote Neo4j instance."""
|
|
138
148
|
console.print("\nTo connect to a hosted Neo4j database, you'll need your connection credentials.")
|
|
149
|
+
console.print("[yellow]Warning: You are configuring to connect to a remote/hosted Neo4j database. Ensure your credentials are secure.[/yellow]")
|
|
139
150
|
console.print("If you don't have a hosted database, you can create a free one at [bold blue]https://neo4j.com/product/auradb/[/bold blue] (click 'Start free').")
|
|
140
151
|
|
|
141
152
|
questions = [
|
|
@@ -265,7 +276,7 @@ services:
|
|
|
265
276
|
- "7474:7474"
|
|
266
277
|
- "7687:7687"
|
|
267
278
|
environment:
|
|
268
|
-
- NEO4J_AUTH=neo4j/
|
|
279
|
+
- NEO4J_AUTH=neo4j/{password}
|
|
269
280
|
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
|
|
270
281
|
volumes:
|
|
271
282
|
- neo4j_data:/data
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -103,11 +103,11 @@ class MCPServer:
|
|
|
103
103
|
},
|
|
104
104
|
"analyze_code_relationships": {
|
|
105
105
|
"name": "analyze_code_relationships",
|
|
106
|
-
"description": "Analyze code relationships like 'who calls this function' or 'class hierarchy'.",
|
|
106
|
+
"description": "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.",
|
|
107
107
|
"inputSchema": {
|
|
108
108
|
"type": "object",
|
|
109
109
|
"properties": {
|
|
110
|
-
"query_type": {"type": "string", "description": "Type of relationship query to run."},
|
|
110
|
+
"query_type": {"type": "string", "description": "Type of relationship query to run.", "enum": ["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"]},
|
|
111
111
|
"target": {"type": "string", "description": "The function, class, or module to analyze."},
|
|
112
112
|
"context": {"type": "string", "description": "Optional: specific file path for precise results."}
|
|
113
113
|
},
|
|
@@ -159,11 +159,12 @@ class MCPServer:
|
|
|
159
159
|
},
|
|
160
160
|
"find_dead_code": {
|
|
161
161
|
"name": "find_dead_code",
|
|
162
|
-
"description": "Find potentially unused functions (dead code) across the entire indexed codebase.",
|
|
162
|
+
"description": "Find potentially unused functions (dead code) across the entire indexed codebase, optionally excluding functions with specific decorators.",
|
|
163
163
|
"inputSchema": {
|
|
164
164
|
"type": "object",
|
|
165
|
-
"properties": {
|
|
166
|
-
|
|
165
|
+
"properties": {
|
|
166
|
+
"exclude_decorated_with": {"type": "array", "items": {"type": "string"}, "description": "Optional: A list of decorator names (e.g., '@app.route') to exclude from dead code detection.", "default": []}
|
|
167
|
+
}
|
|
167
168
|
}
|
|
168
169
|
},
|
|
169
170
|
"calculate_cyclomatic_complexity": {
|
|
@@ -207,7 +208,6 @@ class MCPServer:
|
|
|
207
208
|
"required": ["repo_path"]
|
|
208
209
|
}
|
|
209
210
|
}
|
|
210
|
-
# Other tools like list_imports, add_package_to_graph can be added here following the same pattern
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
def get_database_status(self) -> dict:
|
|
@@ -304,12 +304,12 @@ class MCPServer:
|
|
|
304
304
|
"details": str(e)
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
def find_dead_code_tool(self) -> Dict[str, Any]:
|
|
307
|
+
def find_dead_code_tool(self, **args) -> Dict[str, Any]:
|
|
308
308
|
"""Tool to find potentially dead code across the entire project."""
|
|
309
|
+
exclude_decorated_with = args.get("exclude_decorated_with", [])
|
|
309
310
|
try:
|
|
310
311
|
debug_log("Finding dead code.")
|
|
311
|
-
|
|
312
|
-
results = self.code_finder.find_dead_code()
|
|
312
|
+
results = self.code_finder.find_dead_code(exclude_decorated_with=exclude_decorated_with)
|
|
313
313
|
|
|
314
314
|
return {
|
|
315
315
|
"success": True,
|
|
@@ -446,17 +446,11 @@ class MCPServer:
|
|
|
446
446
|
else:
|
|
447
447
|
return {"error": f"Path {path} does not exist"}
|
|
448
448
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
# 'itertools', 'functools', 'operator', 'pathlib', 'urllib', 'http', 'logging',
|
|
455
|
-
# 'threading', 'multiprocessing', 'asyncio', 'typing', 'dataclasses', 'enum',
|
|
456
|
-
# 'abc', 'io', 'csv', 'sqlite3', 'pickle', 'base64', 'hashlib', 'hmac', 'secrets',
|
|
457
|
-
# 'unittest', 'doctest', 'pdb', 'profile', 'cProfile', 'timeit'
|
|
458
|
-
# }
|
|
459
|
-
all_imports = all_imports - stdlib_modules
|
|
449
|
+
# Removed standard library filtering as per user request.
|
|
450
|
+
# if language == 'python':
|
|
451
|
+
# # Get the list of stdlib modules for the current Python version
|
|
452
|
+
# stdlib_modules = set(stdlibs.module_names)
|
|
453
|
+
# all_imports = all_imports - stdlib_modules
|
|
460
454
|
|
|
461
455
|
return {
|
|
462
456
|
"imports": sorted(list(all_imports)), "language": language,
|
|
@@ -642,8 +636,9 @@ class MCPServer:
|
|
|
642
636
|
return {
|
|
643
637
|
"error": "Both 'query_type' and 'target' are required",
|
|
644
638
|
"supported_query_types": [
|
|
645
|
-
"
|
|
646
|
-
"class_hierarchy", "overrides", "dead_code"
|
|
639
|
+
"find_callers", "find_callees", "find_importers", "who_modifies",
|
|
640
|
+
"class_hierarchy", "overrides", "dead_code", "call_chain",
|
|
641
|
+
"module_deps", "variable_scope", "find_complexity"
|
|
647
642
|
]
|
|
648
643
|
}
|
|
649
644
|
|
|
File without changes
|