ctxgraph 0.5.0__tar.gz → 0.5.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.
Files changed (56) hide show
  1. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/PKG-INFO +26 -5
  2. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/README.md +25 -4
  3. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/pyproject.toml +1 -1
  4. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/mcp/server.py +102 -6
  5. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph.egg-info/PKG-INFO +26 -5
  6. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/setup.cfg +0 -0
  7. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/__init__.py +0 -0
  8. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/analyzers/__init__.py +0 -0
  9. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/analyzers/python/__init__.py +0 -0
  10. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/analyzers/python/importer.py +0 -0
  11. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/analyzers/python/semantic.py +0 -0
  12. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/analyzers/python/symbols.py +0 -0
  13. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/capsule/__init__.py +0 -0
  14. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/capsule/renderer.py +0 -0
  15. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/capsule/savings.py +0 -0
  16. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/chat.py +0 -0
  17. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/cli/__init__.py +0 -0
  18. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/cli/main.py +0 -0
  19. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/clients/__init__.py +0 -0
  20. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/clients/models.py +0 -0
  21. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/config/__init__.py +0 -0
  22. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/config/init.py +0 -0
  23. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/config/providers.py +0 -0
  24. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/config/settings.py +0 -0
  25. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/exclude/__init__.py +0 -0
  26. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/exclude/patterns.py +0 -0
  27. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/graph/__init__.py +0 -0
  28. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/graph/builder.py +0 -0
  29. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/graph/models.py +0 -0
  30. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/graph/query.py +0 -0
  31. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/graph/storage.py +0 -0
  32. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/history.py +0 -0
  33. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/mcp/__init__.py +0 -0
  34. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/skills/__init__.py +0 -0
  35. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/skills/field-guide.toml +0 -0
  36. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/skills/project-style.toml +0 -0
  37. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/skills/template.example.toml +0 -0
  38. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/view/__init__.py +0 -0
  39. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/view/visualizer.py +0 -0
  40. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/wrapper/__init__.py +0 -0
  41. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph/wrapper/claude.py +0 -0
  42. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph.egg-info/SOURCES.txt +0 -0
  43. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph.egg-info/dependency_links.txt +0 -0
  44. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph.egg-info/entry_points.txt +0 -0
  45. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph.egg-info/requires.txt +0 -0
  46. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/src/ctxgraph.egg-info/top_level.txt +0 -0
  47. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/tests/test_analyzers.py +0 -0
  48. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/tests/test_benchmark.py +0 -0
  49. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/tests/test_capsule.py +0 -0
  50. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/tests/test_config.py +0 -0
  51. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/tests/test_e2e.py +0 -0
  52. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/tests/test_integration.py +0 -0
  53. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/tests/test_model_mode.py +0 -0
  54. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/tests/test_models.py +0 -0
  55. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/tests/test_query.py +0 -0
  56. {ctxgraph-0.5.0 → ctxgraph-0.5.2}/tests/test_storage.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ctxgraph
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Summary: 97% cheaper AI coding. ctxgraph builds a knowledge graph of your Python codebase, then generates token-efficient context capsules for any AI tool. Or hook up Ollama/Claude/OpenAI and use it as a code-aware coding assistant — like ChatGPT or Claude Code, but with built-in graph context. Cut token costs by 97%, work offline with just a graph, or connect your favorite LLM.
5
5
  Author: ctxgraph contributors
6
6
  License: MIT
@@ -508,25 +508,46 @@ ctx info
508
508
 
509
509
  ### `ctx serve` — MCP server
510
510
 
511
+ Start the MCP protocol server for Claude Desktop and other MCP-compatible clients to query the knowledge graph directly.
512
+
511
513
  ```bash
512
514
  pip install ctxgraph[mcp]
513
- ctx serve
515
+ ctx serve --repo /path/to/your/project # Explicit path (recommended for Claude Desktop)
516
+ ctx serve # Auto-detect from cwd or CTXGRAPH_REPO_PATH
514
517
  ```
515
518
 
516
- Claude Desktop config:
519
+ **Claude Desktop config** (use `--repo` or your project path):
517
520
 
518
521
  ```json
519
522
  {
520
523
  "mcpServers": {
521
524
  "ctxgraph": {
522
525
  "command": "ctx",
523
- "args": ["serve"]
526
+ "args": ["serve", "--repo", "C:\\Users\\yourname\\projects\\myapp"]
524
527
  }
525
528
  }
526
529
  }
527
530
  ```
528
531
 
529
- Tools: `search_graph`, `get_context_capsule`, `get_file_dependencies`, `get_project_overview`.
532
+ Or set the `CTXGRAPH_REPO_PATH` environment variable instead of passing `--repo`:
533
+
534
+ ```json
535
+ {
536
+ "mcpServers": {
537
+ "ctxgraph": {
538
+ "command": "ctx",
539
+ "args": ["serve"],
540
+ "env": {
541
+ "CTXGRAPH_REPO_PATH": "C:\\Users\\yourname\\projects\\myapp"
542
+ }
543
+ }
544
+ }
545
+ }
546
+ ```
547
+
548
+ Tools: `search_graph`, `get_context_capsule`, `get_file_dependencies`, `get_project_overview`, `read_file`, `search_files`.
549
+
550
+ > **Windows users:** Claude Desktop may not set the working directory to your project root. Always use `--repo` or `CTXGRAPH_REPO_PATH` to ensure the server can find your graph.
530
551
 
531
552
  ---
532
553
 
@@ -479,25 +479,46 @@ ctx info
479
479
 
480
480
  ### `ctx serve` — MCP server
481
481
 
482
+ Start the MCP protocol server for Claude Desktop and other MCP-compatible clients to query the knowledge graph directly.
483
+
482
484
  ```bash
483
485
  pip install ctxgraph[mcp]
484
- ctx serve
486
+ ctx serve --repo /path/to/your/project # Explicit path (recommended for Claude Desktop)
487
+ ctx serve # Auto-detect from cwd or CTXGRAPH_REPO_PATH
485
488
  ```
486
489
 
487
- Claude Desktop config:
490
+ **Claude Desktop config** (use `--repo` or your project path):
488
491
 
489
492
  ```json
490
493
  {
491
494
  "mcpServers": {
492
495
  "ctxgraph": {
493
496
  "command": "ctx",
494
- "args": ["serve"]
497
+ "args": ["serve", "--repo", "C:\\Users\\yourname\\projects\\myapp"]
495
498
  }
496
499
  }
497
500
  }
498
501
  ```
499
502
 
500
- Tools: `search_graph`, `get_context_capsule`, `get_file_dependencies`, `get_project_overview`.
503
+ Or set the `CTXGRAPH_REPO_PATH` environment variable instead of passing `--repo`:
504
+
505
+ ```json
506
+ {
507
+ "mcpServers": {
508
+ "ctxgraph": {
509
+ "command": "ctx",
510
+ "args": ["serve"],
511
+ "env": {
512
+ "CTXGRAPH_REPO_PATH": "C:\\Users\\yourname\\projects\\myapp"
513
+ }
514
+ }
515
+ }
516
+ }
517
+ ```
518
+
519
+ Tools: `search_graph`, `get_context_capsule`, `get_file_dependencies`, `get_project_overview`, `read_file`, `search_files`.
520
+
521
+ > **Windows users:** Claude Desktop may not set the working directory to your project root. Always use `--repo` or `CTXGRAPH_REPO_PATH` to ensure the server can find your graph.
501
522
 
502
523
  ---
503
524
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ctxgraph"
7
- version = "0.5.0"
7
+ version = "0.5.2"
8
8
  description = "97% cheaper AI coding. ctxgraph builds a knowledge graph of your Python codebase, then generates token-efficient context capsules for any AI tool. Or hook up Ollama/Claude/OpenAI and use it as a code-aware coding assistant — like ChatGPT or Claude Code, but with built-in graph context. Cut token costs by 97%, work offline with just a graph, or connect your favorite LLM."
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -8,15 +8,27 @@ directly through tools instead of static context capsules.
8
8
  Protocol: https://modelcontextprotocol.io
9
9
 
10
10
  Usage:
11
- ctx serve # Start MCP server (stdio mode)
12
- ctx serve --port 8080 # Start MCP server (SSE mode)
11
+ ctx serve # Auto-detect from cwd (stdio mode)
12
+ ctx serve --repo /path/to/project # Explicit project root
13
+ ctx serve --port 8080 # SSE mode (not yet supported)
13
14
 
14
- Claude Desktop config:
15
+ Claude Desktop config (with --repo):
15
16
  {
16
17
  "mcpServers": {
17
18
  "ctxgraph": {
18
19
  "command": "ctx",
19
- "args": ["serve"]
20
+ "args": ["serve", "--repo", "C:\\path\\to\\project"]
21
+ }
22
+ }
23
+ }
24
+
25
+ Or via CTXGRAPH_REPO_PATH env var:
26
+ {
27
+ "mcpServers": {
28
+ "ctxgraph": {
29
+ "command": "ctx",
30
+ "args": ["serve"],
31
+ "env": {"CTXGRAPH_REPO_PATH": "C:\\path\\to\\project"}
20
32
  }
21
33
  }
22
34
  }
@@ -25,6 +37,7 @@ Claude Desktop config:
25
37
  from __future__ import annotations
26
38
 
27
39
  import json
40
+ import os
28
41
  import sys
29
42
  from pathlib import Path
30
43
  from typing import Any, Optional
@@ -51,11 +64,23 @@ def _find_repo_root(start: Path) -> Path:
51
64
  return start
52
65
 
53
66
 
67
+ def _resolve_repo_path(repo_path: Optional[str] = None) -> Path:
68
+ if repo_path:
69
+ return Path(repo_path).resolve()
70
+ env_path = os.environ.get("CTXGRAPH_REPO_PATH")
71
+ if env_path:
72
+ return Path(env_path).resolve()
73
+ return _find_repo_root(Path.cwd())
74
+
75
+
54
76
  def create_server(repo_path: Optional[str] = None) -> Optional[Any]:
55
77
  if not HAS_MCP:
56
78
  return None
57
79
 
58
- path = Path(repo_path).resolve() if repo_path else _find_repo_root(Path.cwd())
80
+ path = _resolve_repo_path(repo_path)
81
+ db_path = path / ".ctxgraph" / "graph.db"
82
+ print(f"[ctxgraph] Repo root: {path}", file=sys.stderr)
83
+ print(f"[ctxgraph] Graph DB: {db_path}", file=sys.stderr)
59
84
  storage = get_storage(path)
60
85
 
61
86
  server = Server("ctxgraph")
@@ -124,6 +149,34 @@ def create_server(repo_path: Optional[str] = None) -> Optional[Any]:
124
149
  "properties": {},
125
150
  },
126
151
  ),
152
+ types.Tool(
153
+ name="read_file",
154
+ description="Read the full contents of a source file from the repository",
155
+ inputSchema={
156
+ "type": "object",
157
+ "properties": {
158
+ "file_path": {
159
+ "type": "string",
160
+ "description": "Path to the file (relative to repo root)",
161
+ },
162
+ },
163
+ "required": ["file_path"],
164
+ },
165
+ ),
166
+ types.Tool(
167
+ name="search_files",
168
+ description="Search for files in the repository matching a glob pattern",
169
+ inputSchema={
170
+ "type": "object",
171
+ "properties": {
172
+ "pattern": {
173
+ "type": "string",
174
+ "description": "Glob pattern (e.g. '**/*.py', 'src/**/*service*', '**/*test*')",
175
+ },
176
+ },
177
+ "required": ["pattern"],
178
+ },
179
+ ),
127
180
  ]
128
181
 
129
182
  @server.call_tool()
@@ -137,7 +190,10 @@ def create_server(repo_path: Optional[str] = None) -> Optional[Any]:
137
190
  if storage is None:
138
191
  return [types.TextContent(
139
192
  type="text",
140
- text="No graph found. Run `ctx build` first.",
193
+ text=f"No graph found at: {path / '.ctxgraph' / 'graph.db'}\n\n"
194
+ f"Run `ctx build` in your project root first.\n"
195
+ f"Or set the CTXGRAPH_REPO_PATH environment variable to your project root.\n"
196
+ f"Or pass --repo to ctx serve, e.g. `ctx serve --repo /path/to/project`.",
141
197
  )]
142
198
 
143
199
  if name == "search_graph":
@@ -181,6 +237,46 @@ def create_server(repo_path: Optional[str] = None) -> Optional[Any]:
181
237
  overview = render_project_overview(storage)
182
238
  return [types.TextContent(type="text", text=overview)]
183
239
 
240
+ elif name == "read_file":
241
+ file_path = arguments.get("file_path", "")
242
+ full_path = (path / file_path).resolve()
243
+ if not str(full_path).startswith(str(path.resolve())):
244
+ return [types.TextContent(
245
+ type="text",
246
+ text=f"Access denied: {file_path} is outside the repository root.",
247
+ )]
248
+ if not full_path.exists():
249
+ return [types.TextContent(
250
+ type="text",
251
+ text=f"File not found: {file_path}",
252
+ )]
253
+ if not full_path.is_file():
254
+ return [types.TextContent(
255
+ type="text",
256
+ text=f"Not a file: {file_path}",
257
+ )]
258
+ content = full_path.read_text(encoding="utf-8", errors="replace")
259
+ lines = content.count("\n") + 1
260
+ tokens = max(1, len(content) // 4)
261
+ content += f"\n---\nLine count: {lines} | Tokens: ~{tokens}"
262
+ return [types.TextContent(type="text", text=content)]
263
+
264
+ elif name == "search_files":
265
+ pattern = arguments.get("pattern", "")
266
+ matches = sorted(path.rglob(pattern))
267
+ matches = [m for m in matches if m.is_file()]
268
+ if not matches:
269
+ return [types.TextContent(
270
+ type="text",
271
+ text=f"No files found matching: {pattern}",
272
+ )]
273
+ lines = [f"Files matching '{pattern}':", ""]
274
+ for m in matches[:100]:
275
+ lines.append(f" {m.relative_to(path).as_posix()}")
276
+ if len(matches) > 100:
277
+ lines.append(f" ... and {len(matches) - 100} more")
278
+ return [types.TextContent(type="text", text="\n".join(lines))]
279
+
184
280
  else:
185
281
  return [types.TextContent(type="text", text=f"Unknown tool: {name}")]
186
282
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ctxgraph
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Summary: 97% cheaper AI coding. ctxgraph builds a knowledge graph of your Python codebase, then generates token-efficient context capsules for any AI tool. Or hook up Ollama/Claude/OpenAI and use it as a code-aware coding assistant — like ChatGPT or Claude Code, but with built-in graph context. Cut token costs by 97%, work offline with just a graph, or connect your favorite LLM.
5
5
  Author: ctxgraph contributors
6
6
  License: MIT
@@ -508,25 +508,46 @@ ctx info
508
508
 
509
509
  ### `ctx serve` — MCP server
510
510
 
511
+ Start the MCP protocol server for Claude Desktop and other MCP-compatible clients to query the knowledge graph directly.
512
+
511
513
  ```bash
512
514
  pip install ctxgraph[mcp]
513
- ctx serve
515
+ ctx serve --repo /path/to/your/project # Explicit path (recommended for Claude Desktop)
516
+ ctx serve # Auto-detect from cwd or CTXGRAPH_REPO_PATH
514
517
  ```
515
518
 
516
- Claude Desktop config:
519
+ **Claude Desktop config** (use `--repo` or your project path):
517
520
 
518
521
  ```json
519
522
  {
520
523
  "mcpServers": {
521
524
  "ctxgraph": {
522
525
  "command": "ctx",
523
- "args": ["serve"]
526
+ "args": ["serve", "--repo", "C:\\Users\\yourname\\projects\\myapp"]
524
527
  }
525
528
  }
526
529
  }
527
530
  ```
528
531
 
529
- Tools: `search_graph`, `get_context_capsule`, `get_file_dependencies`, `get_project_overview`.
532
+ Or set the `CTXGRAPH_REPO_PATH` environment variable instead of passing `--repo`:
533
+
534
+ ```json
535
+ {
536
+ "mcpServers": {
537
+ "ctxgraph": {
538
+ "command": "ctx",
539
+ "args": ["serve"],
540
+ "env": {
541
+ "CTXGRAPH_REPO_PATH": "C:\\Users\\yourname\\projects\\myapp"
542
+ }
543
+ }
544
+ }
545
+ }
546
+ ```
547
+
548
+ Tools: `search_graph`, `get_context_capsule`, `get_file_dependencies`, `get_project_overview`, `read_file`, `search_files`.
549
+
550
+ > **Windows users:** Claude Desktop may not set the working directory to your project root. Always use `--repo` or `CTXGRAPH_REPO_PATH` to ensure the server can find your graph.
530
551
 
531
552
  ---
532
553
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes