@nerdsystem/mcp 0.0.0-stage → 0.0.2
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/LICENSE +21 -0
- package/README.md +11 -2
- package/dist/index.js +5 -0
- package/dist/server.js +46 -0
- package/package.json +35 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 nerdsystem
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nerdsystem/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An MCP server for coding agents working on a nerdsystem project. Two tools:
|
|
4
|
+
|
|
5
|
+
- `run_gates`: runs the security gates (secrets, dependencies, platform rules, policy, personal data, typecheck, suppressions, and the built bundle when present) against the working tree and returns failures the agent can act on: rule id, file, line, risk, fix, verify command, attempt count, and whether a person must act instead.
|
|
6
|
+
- `explain_failure`: takes a rule id and returns the risk, the fix, and an example of the wrong and the right pattern.
|
|
7
|
+
|
|
8
|
+
Projects created with `npx nerdsystem init` include the configuration for Claude Code in `.mcp.json`. To add it by hand:
|
|
9
|
+
|
|
10
|
+
```json
|
|
11
|
+
{ "mcpServers": { "nerdsystem": { "command": "npx", "args": ["-y", "@nerdsystem/mcp"] } } }
|
|
12
|
+
```
|
package/dist/index.js
ADDED
package/dist/server.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { RULES, ruleFor } from "nerdsystem/gates";
|
|
4
|
+
import { runVerify } from "nerdsystem/commands/verify";
|
|
5
|
+
import { findProjectRoot } from "nerdsystem/project";
|
|
6
|
+
/**
|
|
7
|
+
* Thin: the gates run from the same library the CLI and the builder use, approved suppressions
|
|
8
|
+
* come from the control plane with the CLI's saved login, and every failure uses the shape the
|
|
9
|
+
* dashboard and GitHub check runs show.
|
|
10
|
+
*/
|
|
11
|
+
export function createServer(cwd = process.cwd()) {
|
|
12
|
+
const server = new McpServer({ name: "nerdsystem", version: "0.0.1" });
|
|
13
|
+
server.registerTool("run_gates", {
|
|
14
|
+
title: "Run nerdsystem security gates",
|
|
15
|
+
description: "Runs the gates a deploy runs (secrets, dependencies, platform rules, acceptable use, personal data, typecheck, suppressions; and the built bundle if dist/ exists) against the working tree. Returns failures with rule_id, file, line, risk, fix, verify, attempt, and audience. Fix every failure with audience \"agent\", then run again; stop and tell the person about anything with audience \"human\" or when `stop` is non-empty.",
|
|
16
|
+
inputSchema: { rule: z.string().optional().describe("Run only this rule id or prefix, e.g. secrets/ or secrets/aws-access-key"), include_build: z.boolean().optional().describe("Also scan dist/ if present (default true)") },
|
|
17
|
+
}, async ({ rule, include_build }) => {
|
|
18
|
+
let root;
|
|
19
|
+
try {
|
|
20
|
+
root = findProjectRoot(cwd);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
return { content: [{ type: "text", text: JSON.stringify({ error: err instanceof Error ? err.message : String(err) }) }], isError: true };
|
|
24
|
+
}
|
|
25
|
+
const out = await runVerify(root, { withBuild: include_build ?? true, stopOnFail: false, quiet: true, onlyRules: rule ? [rule] : undefined });
|
|
26
|
+
const payload = {
|
|
27
|
+
ok: out.ok,
|
|
28
|
+
stop: out.stop,
|
|
29
|
+
failures: out.failures,
|
|
30
|
+
summary: out.results.map((r) => ({ gate: r.name, status: r.status, summary: r.summary })),
|
|
31
|
+
next: out.ok ? "All gates pass. Deploy with `nerd deploy` or push." : out.stop.length ? "Stop: these rules have failed too many times in a row. Tell the person and wait." : out.failures.some((f) => f.audience === "human" && f.severity === "block") ? "Some findings need a person (audience \"human\"). Fix the agent ones, then tell the person about the rest." : "Fix each failure, then call run_gates again (it re-runs every gate).",
|
|
32
|
+
};
|
|
33
|
+
return { content: [{ type: "text", text: JSON.stringify(payload, null, 2) }], isError: !out.ok };
|
|
34
|
+
});
|
|
35
|
+
server.registerTool("explain_failure", {
|
|
36
|
+
title: "Explain a gate rule",
|
|
37
|
+
description: "Given a rule_id from run_gates, returns what could happen, what to change, and a short wrong/right example.",
|
|
38
|
+
inputSchema: { rule_id: z.string().describe("e.g. secrets/stripe-secret or bundle/vite-secret-exposed") },
|
|
39
|
+
}, async ({ rule_id }) => {
|
|
40
|
+
const def = RULES[rule_id] ?? ruleFor(rule_id);
|
|
41
|
+
const known = Boolean(RULES[rule_id]);
|
|
42
|
+
const payload = { rule_id, known, title: def.title, severity: def.severity, audience: def.audience, risk: def.risk, fix: def.fix, example: def.example ?? null, verify: `nerd verify --rule ${rule_id}` };
|
|
43
|
+
return { content: [{ type: "text", text: JSON.stringify(payload, null, 2) }] };
|
|
44
|
+
});
|
|
45
|
+
return server;
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nerdsystem/mcp",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "MCP server that lets coding agents run nerdsystem's security gates and read fix instructions.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"nerdsystem-mcp": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/doobe01/nerdsystem-cloudflare",
|
|
18
|
+
"directory": "packages/mcp"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
25
|
+
"zod": "^4.6.7",
|
|
26
|
+
"nerdsystem": "0.0.2"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^22.0.0",
|
|
30
|
+
"typescript": "^5.9.3",
|
|
31
|
+
"vitest": "^4.1.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -p tsconfig.build.json && chmod +x dist/index.js",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"test": "vitest run"
|
|
37
|
+
}
|
|
6
38
|
}
|