claudenv 1.0.2 → 1.2.0

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.
@@ -0,0 +1,168 @@
1
+ # MCP Server Reference — Registry Search & Configuration
2
+
3
+ ## 1. How to Search the Registry
4
+
5
+ The official MCP Registry API provides a searchable catalog of MCP servers. No authentication required.
6
+
7
+ **Endpoint**: `GET https://registry.modelcontextprotocol.io/v0.1/servers`
8
+
9
+ **Parameters**:
10
+ - `search=<term>` — case-insensitive substring match on server names and descriptions
11
+ - `version=latest` — return only the latest version of each server
12
+ - `limit=<n>` — max results per page (default ~100)
13
+
14
+ **Search strategy**:
15
+ 1. Analyze the project's tech stack from manifest files, configs, and source code
16
+ 2. Extract key technology names (languages, frameworks, databases, cloud services, tools)
17
+ 3. Search each technology individually — specific terms yield better results
18
+
19
+ **Example searches**:
20
+ ```bash
21
+ # Database
22
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=postgres&version=latest&limit=10'
23
+
24
+ # Cloud provider
25
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=aws&version=latest&limit=10'
26
+
27
+ # Monitoring
28
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=sentry&version=latest&limit=10'
29
+
30
+ # Version control
31
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=github&version=latest&limit=10'
32
+ ```
33
+
34
+ ## 2. How to Evaluate and Trust Results
35
+
36
+ ### Primary trust signal: npm download counts
37
+
38
+ For each candidate server that has an npm package, check monthly downloads:
39
+ ```bash
40
+ curl -s 'https://api.npmjs.org/downloads/point/last-month/<npm-package-name>'
41
+ # Returns: { "downloads": N, "package": "...", ... }
42
+ ```
43
+
44
+ - **Filter out** servers with <100 monthly downloads — likely unmaintained or experimental
45
+ - **Prefer** servers with 10,000+ monthly downloads — well-established and community-trusted
46
+ - **Strong signal** at 100,000+ downloads — widely adopted
47
+
48
+ ### Secondary trust signal: GitHub stars
49
+
50
+ If the server has a repository URL, check GitHub stars:
51
+ ```bash
52
+ curl -s 'https://api.github.com/repos/<owner>/<repo>'
53
+ # Check the "stargazers_count" field
54
+ ```
55
+
56
+ - Prefer repos with 100+ stars
57
+ - Stars indicate community interest but downloads are a stronger usage signal
58
+
59
+ ### Additional evaluation criteria
60
+
61
+ - **Prefer `packages` (npm/stdio) over `remotes` (hosted)** — stdio runs locally with no external dependency
62
+ - **Prefer well-known namespaces**: `io.modelcontextprotocol/*`, `io.github.modelcontextprotocol/*` are official
63
+ - **Read descriptions carefully** — pick servers that match the project's actual use case
64
+ - **Skip** servers that appear to be forks, test entries, or clearly unmaintained
65
+ - **When multiple servers exist for the same tech**, pick the one with highest npm downloads
66
+ - **Check `environmentVariables`** — servers requiring many complex env vars may be harder to set up
67
+
68
+ ## 3. How to Build .mcp.json
69
+
70
+ The `.mcp.json` file configures MCP servers for a project. It lives in the project root.
71
+
72
+ **Root structure**:
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "server-name": { ... }
77
+ }
78
+ }
79
+ ```
80
+
81
+ ### stdio servers (npm packages)
82
+
83
+ For servers with a `packages` entry of `registryType: "npm"`:
84
+ ```json
85
+ {
86
+ "mcpServers": {
87
+ "server-name": {
88
+ "command": "npx",
89
+ "args": ["-y", "<package-identifier>@latest"],
90
+ "env": {
91
+ "VAR_NAME": "${VAR_NAME}"
92
+ }
93
+ }
94
+ }
95
+ }
96
+ ```
97
+
98
+ - Add any `packageArguments` with `type: "positional"` to the `args` array after the package name
99
+ - Map `environmentVariables` to the `env` object
100
+ - Use `${ENV_VAR}` placeholders for all variables with `isSecret: true`
101
+ - Non-secret env vars can use literal values when the value is project-specific and non-sensitive
102
+
103
+ ### HTTP/SSE servers (remote)
104
+
105
+ For servers with a `remotes` entry:
106
+ ```json
107
+ {
108
+ "mcpServers": {
109
+ "server-name": {
110
+ "type": "streamable-http",
111
+ "url": "https://example.com/mcp"
112
+ }
113
+ }
114
+ }
115
+ ```
116
+
117
+ Use the `type` and `url` from the remote entry directly. Add `headers` if authentication is needed:
118
+ ```json
119
+ {
120
+ "type": "streamable-http",
121
+ "url": "https://example.com/mcp",
122
+ "headers": {
123
+ "Authorization": "Bearer ${API_KEY}"
124
+ }
125
+ }
126
+ ```
127
+
128
+ ## 4. Well-Known Servers
129
+
130
+ These are hints to help find the best option when search results are noisy. Always verify via the registry API — these names and packages may change.
131
+
132
+ | Technology | Search term | Known namespace | Notes |
133
+ |---|---|---|---|
134
+ | Library docs | `context7` | `io.github.upstash/context7` | Up-to-date docs for any library; useful for most projects |
135
+ | GitHub | `github` | `io.github.modelcontextprotocol/github` | Repo management, PRs, issues |
136
+ | PostgreSQL | `postgres` | `io.github.modelcontextprotocol/postgres` | Database queries; prefer read-only config |
137
+ | Filesystem | `filesystem` | `io.github.modelcontextprotocol/filesystem` | Scoped file access |
138
+ | Fetch | `fetch` | `io.github.modelcontextprotocol/fetch` | Web content retrieval |
139
+ | Sentry | `sentry` | — | Error tracking integration |
140
+ | Stripe | `stripe` | — | Payment API |
141
+ | Docker | `docker` | — | Container management |
142
+ | AWS | `aws` | — | Cloud services |
143
+ | Redis | `redis` | — | Cache and data store |
144
+ | MongoDB | `mongodb` | — | Document database |
145
+ | Slack | `slack` | — | Team communication |
146
+ | Linear | `linear` | — | Issue tracking |
147
+
148
+ ## 5. Security Rules
149
+
150
+ ### Secrets management
151
+ - **NEVER** put actual secret values in `.mcp.json` — use `${ENV_VAR}` placeholders
152
+ - Secret values go in `~/.claude.json` (user-level config, not committed to version control)
153
+ - Tell the user how to configure each secret:
154
+ ```
155
+ claude config set env.VAR_NAME "actual-value"
156
+ ```
157
+
158
+ ### Safe to commit
159
+ - `.mcp.json` is safe to commit to version control — it contains only placeholders, never real secrets
160
+ - Add `.mcp.json` to the git commit alongside other Claude Code config files
161
+
162
+ ### Database safety
163
+ - Prefer read-only database connection strings
164
+ - If read-write access is needed, document this clearly in the recommendation
165
+
166
+ ### Principle of least privilege
167
+ - Only recommend servers that the project actually needs
168
+ - Prefer servers with narrow, well-defined capabilities over general-purpose ones
@@ -0,0 +1,168 @@
1
+ # MCP Server Reference — Registry Search & Configuration
2
+
3
+ ## 1. How to Search the Registry
4
+
5
+ The official MCP Registry API provides a searchable catalog of MCP servers. No authentication required.
6
+
7
+ **Endpoint**: `GET https://registry.modelcontextprotocol.io/v0.1/servers`
8
+
9
+ **Parameters**:
10
+ - `search=<term>` — case-insensitive substring match on server names and descriptions
11
+ - `version=latest` — return only the latest version of each server
12
+ - `limit=<n>` — max results per page (default ~100)
13
+
14
+ **Search strategy**:
15
+ 1. Analyze the project's tech stack from manifest files, configs, and source code
16
+ 2. Extract key technology names (languages, frameworks, databases, cloud services, tools)
17
+ 3. Search each technology individually — specific terms yield better results
18
+
19
+ **Example searches**:
20
+ ```bash
21
+ # Database
22
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=postgres&version=latest&limit=10'
23
+
24
+ # Cloud provider
25
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=aws&version=latest&limit=10'
26
+
27
+ # Monitoring
28
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=sentry&version=latest&limit=10'
29
+
30
+ # Version control
31
+ curl -s 'https://registry.modelcontextprotocol.io/v0.1/servers?search=github&version=latest&limit=10'
32
+ ```
33
+
34
+ ## 2. How to Evaluate and Trust Results
35
+
36
+ ### Primary trust signal: npm download counts
37
+
38
+ For each candidate server that has an npm package, check monthly downloads:
39
+ ```bash
40
+ curl -s 'https://api.npmjs.org/downloads/point/last-month/<npm-package-name>'
41
+ # Returns: { "downloads": N, "package": "...", ... }
42
+ ```
43
+
44
+ - **Filter out** servers with <100 monthly downloads — likely unmaintained or experimental
45
+ - **Prefer** servers with 10,000+ monthly downloads — well-established and community-trusted
46
+ - **Strong signal** at 100,000+ downloads — widely adopted
47
+
48
+ ### Secondary trust signal: GitHub stars
49
+
50
+ If the server has a repository URL, check GitHub stars:
51
+ ```bash
52
+ curl -s 'https://api.github.com/repos/<owner>/<repo>'
53
+ # Check the "stargazers_count" field
54
+ ```
55
+
56
+ - Prefer repos with 100+ stars
57
+ - Stars indicate community interest but downloads are a stronger usage signal
58
+
59
+ ### Additional evaluation criteria
60
+
61
+ - **Prefer `packages` (npm/stdio) over `remotes` (hosted)** — stdio runs locally with no external dependency
62
+ - **Prefer well-known namespaces**: `io.modelcontextprotocol/*`, `io.github.modelcontextprotocol/*` are official
63
+ - **Read descriptions carefully** — pick servers that match the project's actual use case
64
+ - **Skip** servers that appear to be forks, test entries, or clearly unmaintained
65
+ - **When multiple servers exist for the same tech**, pick the one with highest npm downloads
66
+ - **Check `environmentVariables`** — servers requiring many complex env vars may be harder to set up
67
+
68
+ ## 3. How to Build .mcp.json
69
+
70
+ The `.mcp.json` file configures MCP servers for a project. It lives in the project root.
71
+
72
+ **Root structure**:
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "server-name": { ... }
77
+ }
78
+ }
79
+ ```
80
+
81
+ ### stdio servers (npm packages)
82
+
83
+ For servers with a `packages` entry of `registryType: "npm"`:
84
+ ```json
85
+ {
86
+ "mcpServers": {
87
+ "server-name": {
88
+ "command": "npx",
89
+ "args": ["-y", "<package-identifier>@latest"],
90
+ "env": {
91
+ "VAR_NAME": "${VAR_NAME}"
92
+ }
93
+ }
94
+ }
95
+ }
96
+ ```
97
+
98
+ - Add any `packageArguments` with `type: "positional"` to the `args` array after the package name
99
+ - Map `environmentVariables` to the `env` object
100
+ - Use `${ENV_VAR}` placeholders for all variables with `isSecret: true`
101
+ - Non-secret env vars can use literal values when the value is project-specific and non-sensitive
102
+
103
+ ### HTTP/SSE servers (remote)
104
+
105
+ For servers with a `remotes` entry:
106
+ ```json
107
+ {
108
+ "mcpServers": {
109
+ "server-name": {
110
+ "type": "streamable-http",
111
+ "url": "https://example.com/mcp"
112
+ }
113
+ }
114
+ }
115
+ ```
116
+
117
+ Use the `type` and `url` from the remote entry directly. Add `headers` if authentication is needed:
118
+ ```json
119
+ {
120
+ "type": "streamable-http",
121
+ "url": "https://example.com/mcp",
122
+ "headers": {
123
+ "Authorization": "Bearer ${API_KEY}"
124
+ }
125
+ }
126
+ ```
127
+
128
+ ## 4. Well-Known Servers
129
+
130
+ These are hints to help find the best option when search results are noisy. Always verify via the registry API — these names and packages may change.
131
+
132
+ | Technology | Search term | Known namespace | Notes |
133
+ |---|---|---|---|
134
+ | Library docs | `context7` | `io.github.upstash/context7` | Up-to-date docs for any library; useful for most projects |
135
+ | GitHub | `github` | `io.github.modelcontextprotocol/github` | Repo management, PRs, issues |
136
+ | PostgreSQL | `postgres` | `io.github.modelcontextprotocol/postgres` | Database queries; prefer read-only config |
137
+ | Filesystem | `filesystem` | `io.github.modelcontextprotocol/filesystem` | Scoped file access |
138
+ | Fetch | `fetch` | `io.github.modelcontextprotocol/fetch` | Web content retrieval |
139
+ | Sentry | `sentry` | — | Error tracking integration |
140
+ | Stripe | `stripe` | — | Payment API |
141
+ | Docker | `docker` | — | Container management |
142
+ | AWS | `aws` | — | Cloud services |
143
+ | Redis | `redis` | — | Cache and data store |
144
+ | MongoDB | `mongodb` | — | Document database |
145
+ | Slack | `slack` | — | Team communication |
146
+ | Linear | `linear` | — | Issue tracking |
147
+
148
+ ## 5. Security Rules
149
+
150
+ ### Secrets management
151
+ - **NEVER** put actual secret values in `.mcp.json` — use `${ENV_VAR}` placeholders
152
+ - Secret values go in `~/.claude.json` (user-level config, not committed to version control)
153
+ - Tell the user how to configure each secret:
154
+ ```
155
+ claude config set env.VAR_NAME "actual-value"
156
+ ```
157
+
158
+ ### Safe to commit
159
+ - `.mcp.json` is safe to commit to version control — it contains only placeholders, never real secrets
160
+ - Add `.mcp.json` to the git commit alongside other Claude Code config files
161
+
162
+ ### Database safety
163
+ - Prefer read-only database connection strings
164
+ - If read-write access is needed, document this clearly in the recommendation
165
+
166
+ ### Principle of least privilege
167
+ - Only recommend servers that the project actually needs
168
+ - Prefer servers with narrow, well-defined capabilities over general-purpose ones
@@ -0,0 +1,117 @@
1
+ // =============================================
2
+ // Autonomy orchestrator — generates all config files for a profile
3
+ // =============================================
4
+
5
+ import { getProfile } from './profiles.js';
6
+ import {
7
+ generateSettingsJson,
8
+ generatePreToolUseHook,
9
+ generateAuditLogHook,
10
+ generateAliases,
11
+ generateCIWorkflow,
12
+ } from './hooks-gen.js';
13
+ import { detectTechStack } from './detector.js';
14
+
15
+ /**
16
+ * Generate all autonomy config files for a given profile.
17
+ *
18
+ * @param {string} profileName - Profile name (safe, moderate, full, ci)
19
+ * @param {string} projectDir - Project directory path
20
+ * @param {object} [options]
21
+ * @param {object} [options.detected] - Pre-computed tech stack (skips detection)
22
+ * @returns {Promise<{ files: Array<{path: string, content: string}>, profile: object }>}
23
+ */
24
+ export async function generateAutonomyConfig(profileName, projectDir, options = {}) {
25
+ const profile = getProfile(profileName);
26
+ const detected = options.detected || (await detectTechStack(projectDir));
27
+
28
+ const files = [
29
+ {
30
+ path: '.claude/settings.json',
31
+ content: generateSettingsJson(profile, detected),
32
+ },
33
+ {
34
+ path: '.claude/hooks/pre-tool-use.sh',
35
+ content: generatePreToolUseHook(profile, detected),
36
+ },
37
+ {
38
+ path: '.claude/hooks/audit-log.sh',
39
+ content: generateAuditLogHook(),
40
+ },
41
+ {
42
+ path: '.claude/aliases.sh',
43
+ content: generateAliases(profile),
44
+ },
45
+ ];
46
+
47
+ // CI profile: add GitHub Actions workflow
48
+ if (profileName === 'ci' && (!detected.ci || detected.ci === 'github-actions')) {
49
+ files.push({
50
+ path: '.github/workflows/claude-ci.yml',
51
+ content: generateCIWorkflow(),
52
+ });
53
+ }
54
+
55
+ return { files, profile };
56
+ }
57
+
58
+ /**
59
+ * Print a security summary table for a profile.
60
+ * @param {object} profile
61
+ */
62
+ export function printSecuritySummary(profile) {
63
+ console.log(`\n Security summary — ${profile.name} profile\n`);
64
+ console.log(` ${'─'.repeat(50)}`);
65
+
66
+ console.log(` Skip permissions: ${profile.skipPermissions ? 'YES (--dangerously-skip-permissions)' : 'No'}`);
67
+ console.log(` Credential policy: ${profile.credentialPolicy}`);
68
+
69
+ if (profile.allowedTools && profile.allowedTools.length > 0) {
70
+ console.log(` Allowed tools: ${profile.allowedTools.length} tool(s)`);
71
+ for (const t of profile.allowedTools) {
72
+ console.log(` + ${t}`);
73
+ }
74
+ }
75
+
76
+ if (profile.disallowedTools && profile.disallowedTools.length > 0) {
77
+ console.log(` Blocked tools: ${profile.disallowedTools.length} tool(s)`);
78
+ for (const t of profile.disallowedTools) {
79
+ console.log(` - ${t}`);
80
+ }
81
+ }
82
+
83
+ if (profile.maxTurns) {
84
+ console.log(` Max turns: ${profile.maxTurns}`);
85
+ }
86
+ if (profile.maxBudget) {
87
+ console.log(` Max budget: $${profile.maxBudget}`);
88
+ }
89
+
90
+ console.log(` ${'─'.repeat(50)}`);
91
+
92
+ // Hard blocks (all profiles)
93
+ console.log(`\n Hard blocks (all profiles):`);
94
+ console.log(` - rm -rf / rm -fr`);
95
+ console.log(` - Force push to main/master`);
96
+ console.log(` - sudo commands`);
97
+
98
+ console.log();
99
+ }
100
+
101
+ /**
102
+ * Full autonomy mode warning text.
103
+ * @returns {string}
104
+ */
105
+ export function getFullModeWarning() {
106
+ return `
107
+ ⚠️ FULL AUTONOMY MODE — UNRESTRICTED ACCESS
108
+
109
+ This profile grants Claude Code complete access including:
110
+ • All file system operations (read, write, delete)
111
+ • Credential files (~/.ssh, ~/.aws, ~/.gnupg, ~/.kube, etc.)
112
+ • All git operations including force push
113
+ • No permission prompts (--dangerously-skip-permissions)
114
+
115
+ Safety net: audit logging + hard blocks on rm -rf / and force push to main
116
+ `;
117
+ }