@getcodesentinel/codesentinel 1.42.1 → 1.43.1
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.
- package/README.md +105 -0
- package/dist/index.js +958 -16
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -608,6 +608,111 @@ A single-file target still starts at that file. From there a greedy walk scores
|
|
|
608
608
|
|
|
609
609
|
`--ref` pins `CODEOWNERS` and the tracked history, while the structural graph and churn come from the working tree. The suggested test command is only a suggestion: nothing is discovered and nothing is run.
|
|
610
610
|
|
|
611
|
+
## MCP server
|
|
612
|
+
|
|
613
|
+
`codesentinel mcp` serves the ownership, risk, trend and reading-path data that CodeSentinel already computes to MCP clients over stdio. It uses JSON-RPC on stdin/stdout and writes every log to stderr. All tools are read-only except `run_scan`, which analyzes the repository and writes a snapshot under `.codesentinel/snapshots`.
|
|
614
|
+
|
|
615
|
+
### Register it
|
|
616
|
+
|
|
617
|
+
Claude Code:
|
|
618
|
+
|
|
619
|
+
```bash
|
|
620
|
+
claude mcp add codesentinel --env CODESENTINEL_ROOT=/absolute/path/to/repository -- codesentinel mcp
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
Claude Desktop (`claude_desktop_config.json`):
|
|
624
|
+
|
|
625
|
+
```json
|
|
626
|
+
{
|
|
627
|
+
"mcpServers": {
|
|
628
|
+
"codesentinel": {
|
|
629
|
+
"command": "npx",
|
|
630
|
+
"args": ["-y", "@getcodesentinel/mcp"],
|
|
631
|
+
"env": { "CODESENTINEL_ROOT": "/absolute/path/to/repository" }
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
Cursor (`.cursor/mcp.json`):
|
|
638
|
+
|
|
639
|
+
```json
|
|
640
|
+
{
|
|
641
|
+
"mcpServers": {
|
|
642
|
+
"codesentinel": {
|
|
643
|
+
"command": "npx",
|
|
644
|
+
"args": ["-y", "@getcodesentinel/mcp"],
|
|
645
|
+
"env": { "CODESENTINEL_ROOT": "/absolute/path/to/repository" }
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
VS Code (`.vscode/mcp.json`):
|
|
652
|
+
|
|
653
|
+
```json
|
|
654
|
+
{
|
|
655
|
+
"servers": {
|
|
656
|
+
"codesentinel": {
|
|
657
|
+
"type": "stdio",
|
|
658
|
+
"command": "npx",
|
|
659
|
+
"args": ["-y", "@getcodesentinel/mcp"],
|
|
660
|
+
"env": { "CODESENTINEL_ROOT": "/absolute/path/to/repository" }
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
Set `CODESENTINEL_ROOT` whenever the client does not start the process from the repository root. `codesentinel mcp` and `npx -y @getcodesentinel/mcp` launch the same server; the wrapper only forwards arguments.
|
|
667
|
+
|
|
668
|
+
### Tools
|
|
669
|
+
|
|
670
|
+
| Tool | Parameters | Returns | Read-only |
|
|
671
|
+
| ------------------ | ------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------- |
|
|
672
|
+
| `get_file_owner` | `path` | Declared owners, observed authorship, criticality and warnings for one tracked file. | yes |
|
|
673
|
+
| `get_file_risk` | `path`, `ref?` (only `HEAD`) | File risk score, normalized score, factor breakdown, hotspot rank and repository score. | yes |
|
|
674
|
+
| `get_reading_path` | `target`, `maxSteps?` | Ordered reading steps with roles, reasons, owners, people and suggested commands. | yes |
|
|
675
|
+
| `get_trend` | `metric`, `path?` (unsupported), `since?`, `until?` | Repository-level metric series from snapshot artifacts, oldest to newest. | yes |
|
|
676
|
+
| `list_hotspots` | `limit?`, `cursor?` | Ranked hotspots with cursor pagination. | yes |
|
|
677
|
+
| `run_scan` | `path?`, `changedOnly?` | Fresh analysis written to a new snapshot file, plus scope and changed-file hotspots. | no |
|
|
678
|
+
| `search_findings` | `path?`, `severity?`, `rule?`, `status?`, `cursor?`, `limit?` | Ownership findings with severity, status, message and CODEOWNERS line. | yes |
|
|
679
|
+
|
|
680
|
+
A real `get_file_owner` call against this repository:
|
|
681
|
+
|
|
682
|
+
```json
|
|
683
|
+
{
|
|
684
|
+
"path": "packages/ownership/src/index.ts",
|
|
685
|
+
"ref": "HEAD",
|
|
686
|
+
"owners": [{ "kind": "user", "value": "@aleixalonso" }],
|
|
687
|
+
"teams": [],
|
|
688
|
+
"status": "aligned",
|
|
689
|
+
"matchLine": 1,
|
|
690
|
+
"topAuthor": { "id": "aleixalonso@users.noreply.github.com", "share": 1 },
|
|
691
|
+
"observed": {
|
|
692
|
+
"commits": 3,
|
|
693
|
+
"recentCommits": 3,
|
|
694
|
+
"authors": 1,
|
|
695
|
+
"dormant": false,
|
|
696
|
+
"busFactor": null,
|
|
697
|
+
"lastCommitUnix": 1792689223
|
|
698
|
+
},
|
|
699
|
+
"criticality": { "isCritical": true, "isHotspot": false, "fanIn": 5, "riskScore": null },
|
|
700
|
+
"warnings": [
|
|
701
|
+
"Ignored 183 commits attributed to 3 ignored authors matched by \"ignoreAuthors\": 29139614+renovate[bot]@users.noreply.github.com, 49699333+dependabot[bot]@users.noreply.github.com, semantic-release-bot@martynus.net."
|
|
702
|
+
]
|
|
703
|
+
}
|
|
704
|
+
```
|
|
705
|
+
|
|
706
|
+
The full request/response capture is in [`docs/mcp-transcript.md`](docs/mcp-transcript.md).
|
|
707
|
+
|
|
708
|
+
### Security
|
|
709
|
+
|
|
710
|
+
No credentials are accepted as tool arguments. Git and CI credentials come from the environment (credential helper, SSH agent or CI token), and error messages are redacted. Stdout carries only MCP messages; logs go to stderr. The server never accepts a token, password or remote URL as a tool input.
|
|
711
|
+
|
|
712
|
+
### Trend source
|
|
713
|
+
|
|
714
|
+
`get_trend` reads snapshots from `CODESENTINEL_SNAPSHOTS_DIR`, defaulting to `<root>/.codesentinel/snapshots`. Snapshots are repository-level, so `get_trend` does not support `path`; use `search_findings` or `get_file_risk` for per-file questions.
|
|
715
|
+
|
|
611
716
|
## Trend
|
|
612
717
|
|
|
613
718
|
`codesentinel trend` reads snapshot JSON artifacts written by `codesentinel ci --snapshot` and prints the series over time. Snapshots are CI artifacts, not repository files: `trend` never writes history into the repository and never changes the snapshot schema.
|