codegraphcontext 0.1.1__tar.gz → 0.1.2__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.1/src/codegraphcontext.egg-info → codegraphcontext-0.1.2}/PKG-INFO +1 -1
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/pyproject.toml +1 -1
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/cli/main.py +1 -6
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/cli/setup_wizard.py +91 -61
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2/src/codegraphcontext.egg-info}/PKG-INFO +1 -1
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/LICENSE +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/README.md +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/setup.cfg +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/__init__.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/__main__.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/cli/__init__.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/core/__init__.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/core/database.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/core/jobs.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/core/watcher.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/prompts.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/server.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/tools/__init__.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/tools/code_finder.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/tools/graph_builder.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/tools/import_extractor.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/tools/system.py +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext.egg-info/SOURCES.txt +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext.egg-info/dependency_links.txt +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext.egg-info/entry_points.txt +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext.egg-info/requires.txt +0 -0
- {codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codegraphcontext
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "codegraphcontext"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.2"
|
|
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"
|
|
@@ -3,17 +3,12 @@ import typer
|
|
|
3
3
|
from rich.console import Console
|
|
4
4
|
import asyncio
|
|
5
5
|
import logging
|
|
6
|
-
from dotenv import load_dotenv
|
|
7
|
-
|
|
8
|
-
from .setup_wizard import run_setup_wizard
|
|
9
6
|
from codegraphcontext.server import MCPServer
|
|
7
|
+
from .setup_wizard import run_setup_wizard
|
|
10
8
|
|
|
11
9
|
# Set the log level for the noisy neo4j logger to WARNING
|
|
12
10
|
logging.getLogger("neo4j").setLevel(logging.WARNING) # <-- ADD THIS LINE
|
|
13
11
|
|
|
14
|
-
# Load environment variables from .env file at the very beginning
|
|
15
|
-
load_dotenv()
|
|
16
|
-
|
|
17
12
|
app = typer.Typer(
|
|
18
13
|
name="cgc",
|
|
19
14
|
help="CodeGraphContext: An MCP server for AI-powered code analysis.",
|
|
@@ -5,12 +5,54 @@ import platform
|
|
|
5
5
|
import os
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
import time
|
|
8
|
+
import json
|
|
9
|
+
import sys
|
|
8
10
|
|
|
9
11
|
console = Console()
|
|
10
12
|
|
|
13
|
+
def _generate_mcp_json(creds):
|
|
14
|
+
"""Generates and prints the MCP JSON configuration."""
|
|
15
|
+
cgc_path = sys.executable # Path to the python executable in the current venv
|
|
16
|
+
|
|
17
|
+
mcp_config = {
|
|
18
|
+
"mcpServers": {
|
|
19
|
+
"CodeGraphContext": {
|
|
20
|
+
"command": cgc_path,
|
|
21
|
+
"args": ["start"],
|
|
22
|
+
"env": {
|
|
23
|
+
"NEO4J_URI": creds.get("uri", ""),
|
|
24
|
+
"NEO4J_USER": creds.get("username", "neo4j"),
|
|
25
|
+
"NEO4J_PASSWORD": creds.get("password", "")
|
|
26
|
+
},
|
|
27
|
+
"tools": {
|
|
28
|
+
"alwaysAllow": [
|
|
29
|
+
"list_imports", "add_code_to_graph", "add_package_to_graph",
|
|
30
|
+
"check_job_status", "list_jobs", "find_code",
|
|
31
|
+
"analyze_code_relationships", "watch_directory",
|
|
32
|
+
"find_dead_code", "execute_cypher_query"
|
|
33
|
+
],
|
|
34
|
+
"disabled": False
|
|
35
|
+
},
|
|
36
|
+
"disabled": False,
|
|
37
|
+
"alwaysAllow": []
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.print("\n[bold green]Configuration successful![/bold green]")
|
|
43
|
+
console.print("Copy the following JSON and add it to your MCP server configuration file:")
|
|
44
|
+
console.print(json.dumps(mcp_config, indent=2))
|
|
45
|
+
|
|
46
|
+
# Also save to a file for convenience
|
|
47
|
+
mcp_file = Path.cwd() / "mcp.json"
|
|
48
|
+
with open(mcp_file, "w") as f:
|
|
49
|
+
json.dump(mcp_config, f, indent=2)
|
|
50
|
+
console.print(f"\n[cyan]For your convenience, the configuration has also been saved to: {mcp_file}[/cyan]")
|
|
51
|
+
|
|
52
|
+
|
|
11
53
|
def get_project_root() -> Path:
|
|
12
|
-
"""
|
|
13
|
-
return Path
|
|
54
|
+
"""Always return the directory where the user runs `cgc` (CWD)."""
|
|
55
|
+
return Path.cwd()
|
|
14
56
|
|
|
15
57
|
def run_command(command, console, shell=False, check=True, input_text=None):
|
|
16
58
|
"""
|
|
@@ -78,31 +120,7 @@ def find_latest_neo4j_creds_file():
|
|
|
78
120
|
latest_file = max(cred_files, key=lambda f: f.stat().st_mtime)
|
|
79
121
|
return latest_file
|
|
80
122
|
|
|
81
|
-
|
|
82
|
-
"""Parses a credentials file and writes to .env."""
|
|
83
|
-
try:
|
|
84
|
-
creds = {}
|
|
85
|
-
with open(file_path, "r") as f:
|
|
86
|
-
for line in f:
|
|
87
|
-
if "=" in line:
|
|
88
|
-
key, value = line.strip().split("=", 1)
|
|
89
|
-
if key in ["NEO4J_URI", "NEO4J_USERNAME", "NEO4J_PASSWORD"]:
|
|
90
|
-
creds[key] = value
|
|
91
|
-
|
|
92
|
-
if all(k in creds for k in ["NEO4J_URI", "NEO4J_USERNAME", "NEO4J_PASSWORD"]):
|
|
93
|
-
env_path = get_project_root() / ".env"
|
|
94
|
-
with open(env_path, "w") as f:
|
|
95
|
-
f.write(f"NEO4J_URI={creds['NEO4J_URI']}\n")
|
|
96
|
-
f.write(f"NEO4J_USERNAME={creds['NEO4J_USERNAME']}\n")
|
|
97
|
-
f.write(f"NEO4J_PASSWORD={creds['NEO4J_PASSWORD']}\n")
|
|
98
|
-
console.print(f"[green]✅ Configuration from {file_path.name} saved to .env file in project root.[/green]")
|
|
99
|
-
return True
|
|
100
|
-
else:
|
|
101
|
-
console.print("[red]❌ The credentials file is missing one or more required keys (NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD).[/red]")
|
|
102
|
-
return False
|
|
103
|
-
except Exception as e:
|
|
104
|
-
console.print(f"[red]❌ Failed to parse credentials file: {e}[/red]")
|
|
105
|
-
return False
|
|
123
|
+
|
|
106
124
|
|
|
107
125
|
def setup_hosted_db():
|
|
108
126
|
"""Guides user to configure a remote Neo4j instance."""
|
|
@@ -117,8 +135,10 @@ def setup_hosted_db():
|
|
|
117
135
|
result = prompt(questions)
|
|
118
136
|
cred_method = result.get("cred_method")
|
|
119
137
|
|
|
138
|
+
creds = {}
|
|
120
139
|
if cred_method and "file" in cred_method:
|
|
121
140
|
latest_file = find_latest_neo4j_creds_file()
|
|
141
|
+
file_to_parse = None
|
|
122
142
|
if latest_file:
|
|
123
143
|
confirm_questions = [
|
|
124
144
|
{
|
|
@@ -129,38 +149,51 @@ def setup_hosted_db():
|
|
|
129
149
|
}
|
|
130
150
|
]
|
|
131
151
|
if prompt(confirm_questions).get("use_latest"):
|
|
132
|
-
|
|
133
|
-
return
|
|
152
|
+
file_to_parse = latest_file
|
|
134
153
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
154
|
+
if not file_to_parse:
|
|
155
|
+
path_questions = [
|
|
156
|
+
{"type": "input", "message": "Please enter the path to your credentials file:", "name": "cred_file_path"}
|
|
157
|
+
]
|
|
158
|
+
file_path_str = prompt(path_questions).get("cred_file_path", "")
|
|
159
|
+
file_path = Path(file_path_str.strip())
|
|
160
|
+
if file_path.exists() and file_path.is_file():
|
|
161
|
+
file_to_parse = file_path
|
|
162
|
+
else:
|
|
163
|
+
console.print("[red]❌ The specified file path does not exist or is not a file.[/red]")
|
|
164
|
+
return
|
|
165
|
+
|
|
166
|
+
if file_to_parse:
|
|
167
|
+
try:
|
|
168
|
+
with open(file_to_parse, "r") as f:
|
|
169
|
+
for line in f:
|
|
170
|
+
if "=" in line:
|
|
171
|
+
key, value = line.strip().split("=", 1)
|
|
172
|
+
if key == "NEO4J_URI":
|
|
173
|
+
creds["uri"] = value
|
|
174
|
+
elif key == "NEO4J_USERNAME":
|
|
175
|
+
creds["username"] = value
|
|
176
|
+
elif key == "NEO4J_PASSWORD":
|
|
177
|
+
creds["password"] = value
|
|
178
|
+
except Exception as e:
|
|
179
|
+
console.print(f"[red]❌ Failed to parse credentials file: {e}[/red]")
|
|
180
|
+
return
|
|
145
181
|
|
|
146
|
-
elif cred_method:
|
|
182
|
+
elif cred_method: # Manual entry
|
|
147
183
|
console.print("Please enter your remote Neo4j connection details.")
|
|
148
184
|
questions = [
|
|
149
185
|
{"type": "input", "message": "URI (e.g., neo4j+s://xxxx.databases.neo4j.io):", "name": "uri"},
|
|
150
186
|
{"type": "input", "message": "Username:", "name": "username", "default": "neo4j"},
|
|
151
187
|
{"type": "password", "message": "Password:", "name": "password"},
|
|
152
188
|
]
|
|
153
|
-
|
|
154
|
-
if not
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
console.print("[green]✅ Configuration for hosted database saved to .env file in project root.[/green]")
|
|
162
|
-
except Exception as e:
|
|
163
|
-
console.print(f"[red]❌ Failed to write .env file: {e}[/red]")
|
|
189
|
+
manual_creds = prompt(questions)
|
|
190
|
+
if not manual_creds: return # User cancelled
|
|
191
|
+
creds = manual_creds
|
|
192
|
+
|
|
193
|
+
if creds.get("uri") and creds.get("password"):
|
|
194
|
+
_generate_mcp_json(creds)
|
|
195
|
+
else:
|
|
196
|
+
console.print("[red]❌ Incomplete credentials. Please try again.[/red]")
|
|
164
197
|
|
|
165
198
|
def setup_local_db():
|
|
166
199
|
"""Guides user to set up a local Neo4j instance."""
|
|
@@ -271,13 +304,10 @@ def setup_local_binary():
|
|
|
271
304
|
console.print("\n[yellow]Waiting 10 seconds for the database to become available...""")
|
|
272
305
|
time.sleep(10)
|
|
273
306
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
console.print("\n[bold green]All done! Your local Neo4j instance is ready to use.[/bold green]")
|
|
282
|
-
except Exception as e:
|
|
283
|
-
console.print(f"[bold red]Failed to write .env file:[/bold red] {e}")
|
|
307
|
+
creds = {
|
|
308
|
+
"uri": "neo4j://localhost:7687",
|
|
309
|
+
"username": "neo4j",
|
|
310
|
+
"password": new_password
|
|
311
|
+
}
|
|
312
|
+
_generate_mcp_json(creds)
|
|
313
|
+
console.print("\n[bold green]All done! Your local Neo4j instance is ready to use.[/bold green]")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: codegraphcontext
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/tools/graph_builder.py
RENAMED
|
File without changes
|
{codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext/tools/import_extractor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext.egg-info/requires.txt
RENAMED
|
File without changes
|
{codegraphcontext-0.1.1 → codegraphcontext-0.1.2}/src/codegraphcontext.egg-info/top_level.txt
RENAMED
|
File without changes
|