Skip to content

Commit 7581fba

Browse files
PatrickSysclaude
andauthored
feat: expose all 10 MCP tools via CLI + document them (#42)
* test: decision card output shape and scope-prefixed snippets * docs: release notes for ranked search and edit decision card * sanitize docs, one last moment fix * feat: expose all 10 MCP tools via CLI + document them - Add handleCliCommand() in src/cli.ts with 8 new subcommands: search, metadata, status, reindex, style-guide, patterns, refs, cycles - Each maps 1:1 to existing tool handlers via dispatchTool() - Create initToolContext() that builds ToolContext from persisted index - Add required-flag validation (--query for search, --symbol for refs) - Support --json flag for scripting/piping - Update src/index.ts routing to send CLI_SUBCOMMANDS to handleCliCommand - Expand README "CLI Access" → "CLI Reference" with all 9 commands - Add "CLI Reference" section to docs/capabilities.md with command table CLI now enables vendor-neutral access for scripting, debugging, and CI. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> * refactor: clean up imports and improve error handling - Removed unused import of Memory from src/index.ts. - Simplified error message construction in src/core/symbol-references.ts. - Reorganized risk level calculation in src/tools/search-codebase.ts for clarity and consistency. - Added a TODO comment for reviewing confidence calculation in src/tools/search-codebase.ts. * refactor: update risk level calculation in search-codebase.ts - Renamed riskLevel variable to _riskLevel for clarity. - Added a TODO comment to review the risk level calculation logic. - Adjusted risk level assignment based on cycle count and impact candidates. * refactor: clean up CLI command output and improve error message formatting - Consolidated console.log statements in src/cli.ts for better readability. - Enhanced error message formatting in src/core/symbol-references.ts and src/tools/search-codebase.ts for consistency. - Streamlined conditional object construction in src/tools/search-codebase.ts for clarity. --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent ac4389d commit 7581fba

File tree

8 files changed

+572
-217
lines changed

8 files changed

+572
-217
lines changed

README.md

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -287,31 +287,52 @@ Structured filters available: `framework`, `language`, `componentType`, `layer`
287287
!.codebase-context/memory.json
288288
```
289289

290-
## CLI Access (Vendor-Neutral)
290+
## CLI Reference
291291

292-
You can manage team memory directly from the terminal without any AI agent:
292+
All MCP tools are available as CLI commands — no AI agent required. Useful for scripting, debugging, and CI workflows.
293+
294+
Set `CODEBASE_ROOT` to your project root, or run from the project directory.
293295

294296
```bash
295-
# List all memories
296-
npx codebase-context memory list
297+
# Search the indexed codebase
298+
npx codebase-context search --query "authentication middleware"
299+
npx codebase-context search --query "auth" --intent edit --limit 5
297300

298-
# Filter by category or type
299-
npx codebase-context memory list --category conventions --type convention
301+
# Project structure, frameworks, and dependencies
302+
npx codebase-context metadata
300303

301-
# Search memories
302-
npx codebase-context memory list --query "auth"
304+
# Index state and progress
305+
npx codebase-context status
303306

304-
# Add a memory
305-
npx codebase-context memory add --type convention --category tooling --memory "Use pnpm, not npm" --reason "Workspace support and speed"
307+
# Re-index the codebase
308+
npx codebase-context reindex
309+
npx codebase-context reindex --incremental --reason "added new service"
306310

307-
# Remove a memory
308-
npx codebase-context memory remove <id>
311+
# Style guide rules
312+
npx codebase-context style-guide
313+
npx codebase-context style-guide --query "naming" --category patterns
314+
315+
# Team patterns (DI, state, testing, etc.)
316+
npx codebase-context patterns
317+
npx codebase-context patterns --category testing
309318

310-
# JSON output for scripting
311-
npx codebase-context memory list --json
319+
# Symbol references
320+
npx codebase-context refs --symbol "UserService"
321+
npx codebase-context refs --symbol "handleLogin" --limit 20
322+
323+
# Circular dependency detection
324+
npx codebase-context cycles
325+
npx codebase-context cycles --scope src/features
326+
327+
# Memory management
328+
npx codebase-context memory list
329+
npx codebase-context memory list --category conventions --type convention
330+
npx codebase-context memory list --query "auth" --json
331+
npx codebase-context memory add --type convention --category tooling --memory "Use pnpm, not npm" --reason "Workspace support and speed"
332+
npx codebase-context memory remove <id>
312333
```
313334

314-
Set `CODEBASE_ROOT` to point to your project, or run from the project directory.
335+
All commands accept `--json` for raw JSON output suitable for piping and scripting.
315336

316337
## Tip: Ensuring your AI Agent recalls memory:
317338

docs/capabilities.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,35 @@
22

33
Technical reference for what `codebase-context` ships today. For the user-facing overview, see [README.md](../README.md).
44

5+
## CLI Reference
6+
7+
All 10 MCP tools are exposed as CLI subcommands. Set `CODEBASE_ROOT` or run from the project directory.
8+
9+
| Command | Flags | Maps to |
10+
|---|---|---|
11+
| `search --query <q>` | `--intent explore\|edit\|refactor\|migrate`, `--limit <n>`, `--lang <l>`, `--framework <f>`, `--layer <l>` | `search_codebase` |
12+
| `metadata` || `get_codebase_metadata` |
13+
| `status` || `get_indexing_status` |
14+
| `reindex` | `--incremental`, `--reason <r>` | `refresh_index` |
15+
| `style-guide` | `--query <q>`, `--category <c>` | `get_style_guide` |
16+
| `patterns` | `--category all\|di\|state\|testing\|libraries` | `get_team_patterns` |
17+
| `refs --symbol <name>` | `--limit <n>` | `get_symbol_references` |
18+
| `cycles` | `--scope <path>` | `detect_circular_dependencies` |
19+
| `memory list` | `--category`, `--type`, `--query`, `--json` ||
20+
| `memory add` | `--type`, `--category`, `--memory`, `--reason` | `remember` |
21+
| `memory remove <id>` |||
22+
23+
All commands accept `--json` for raw JSON output. Errors go to stderr with exit code 1.
24+
25+
```bash
26+
# Quick examples
27+
npx codebase-context status
28+
npx codebase-context search --query "auth middleware" --intent edit
29+
npx codebase-context refs --symbol "UserService" --limit 10
30+
npx codebase-context cycles --scope src/features
31+
npx codebase-context reindex --incremental
32+
```
33+
534
## Tool Surface
635

736
10 MCP tools + 1 optional resource (`codebase://context`). **Migration:** `get_component_usage` was removed; use `get_symbol_references` for symbol usage evidence.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
"@typescript-eslint/typescript-estree": "^7.0.0",
129129
"fuse.js": "^7.0.0",
130130
"glob": "^10.3.10",
131-
"hono": "4.11.7",
131+
"hono": "^4.11.10",
132132
"ignore": "^5.3.1",
133133
"typescript": "^5.3.3",
134134
"uuid": "^9.0.1",
@@ -142,7 +142,7 @@
142142
"@types/uuid": "^9.0.8",
143143
"@typescript-eslint/eslint-plugin": "^8.51.0",
144144
"@typescript-eslint/parser": "^8.51.0",
145-
"eslint": "^10.0.1",
145+
"eslint": "^9.0.0",
146146
"eslint-config-prettier": "^10.1.8",
147147
"eslint-plugin-import": "^2.32.0",
148148
"globals": "^17.0.0",
@@ -160,7 +160,8 @@
160160
"sharp"
161161
],
162162
"overrides": {
163-
"@modelcontextprotocol/sdk>ajv": "8.18.0"
163+
"@modelcontextprotocol/sdk>ajv": "8.18.0",
164+
"minimatch": ">=10.2.1"
164165
}
165166
}
166167
}

0 commit comments

Comments
 (0)