@socketsecurity/mcp 0.0.17 → 0.0.18
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/CHANGELOG.md +19 -0
- package/README.md +221 -184
- package/dist/index.cjs +58128 -0
- package/dist/index.d.ts +4 -0
- package/hooks/socket-gate/README.md +117 -0
- package/hooks/socket-gate/index.mts +289 -0
- package/hooks/socket-gate/socket-gate.cjs +1047 -0
- package/package.json +90 -65
- package/index.d.ts +0 -3
- package/index.d.ts.map +0 -1
- package/index.js +0 -460
- package/mock-client/debug-client.d.ts +0 -3
- package/mock-client/debug-client.d.ts.map +0 -1
- package/mock-client/debug-client.js +0 -134
- package/mock-client/http-client.d.ts +0 -3
- package/mock-client/http-client.d.ts.map +0 -1
- package/mock-client/http-client.js +0 -123
- package/mock-client/stdio-client.d.ts +0 -3
- package/mock-client/stdio-client.d.ts.map +0 -1
- package/mock-client/stdio-client.js +0 -52
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@socketsecurity/mcp` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.0.18]
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- The `package_files` and `organizations` tools no longer fail with
|
|
15
|
+
`Unexpected token` JSON errors against the live Socket API.
|
|
16
|
+
|
|
17
|
+
## [0.0.17]
|
|
18
|
+
|
|
19
|
+
Initial tracked release.
|
package/README.md
CHANGED
|
@@ -4,11 +4,15 @@
|
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://socket.dev/npm/package/@socketsecurity/mcp)
|
|
6
6
|
|
|
7
|
-
A Model Context Protocol (MCP) server for Socket integration
|
|
7
|
+
A Model Context Protocol (MCP) server for Socket integration — lets AI assistants query dependency vulnerability scores and security metadata.
|
|
8
|
+
|
|
9
|
+
## Why this repo exists
|
|
10
|
+
|
|
11
|
+
Socket MCP exposes Socket.dev's package-scoring API through the Model Context Protocol, so any MCP-aware AI assistant (Claude, VS Code Copilot, Cursor, Windsurf) can score a package, audit a `package.json`, or flag risky dependencies as part of a conversation. It ships as both a hosted public server (`https://mcp.socket.dev/`, no setup) and a self-hostable npm package, so you can choose between zero-friction and full data isolation.
|
|
8
12
|
|
|
9
13
|
## ✨ Features
|
|
10
14
|
|
|
11
|
-
- 🔍 **Dependency Security Scanning** - Get comprehensive security scores for npm, PyPI, and
|
|
15
|
+
- 🔍 **Dependency Security Scanning** - Get comprehensive security scores for npm, PyPI, cargo, Maven, NuGet, RubyGems, Go Modules, and more ([supported ecosystems](https://docs.socket.dev/docs/language-support))
|
|
12
16
|
- 🌐 **Public Hosted Service** - Use our public server at `https://mcp.socket.dev/` with no setup required
|
|
13
17
|
- 🚀 **Multiple Deployment Options** - Run locally via stdio, HTTP, or use our service
|
|
14
18
|
- 🤖 **AI Assistant Integration** - Works seamlessly with Claude, VS Code Copilot, Cursor, and other MCP clients
|
|
@@ -17,28 +21,21 @@ A Model Context Protocol (MCP) server for Socket integration, allowing AI assist
|
|
|
17
21
|
|
|
18
22
|
🛠️ This project is in early development and rapidly evolving.
|
|
19
23
|
|
|
20
|
-
##
|
|
21
|
-
|
|
22
|
-
### Option 1: Use the Public Socket MCP Server (Recommended)
|
|
24
|
+
## Install
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
### Option 1: Use the public Socket MCP server (recommended)
|
|
25
27
|
|
|
28
|
+
The easiest way to get started. **No API key or authentication required!** Click a button below to install in your favorite AI assistant.
|
|
26
29
|
|
|
27
30
|
[](https://vscode.dev/redirect/mcp/install?name=socket-mcp&config={"url":"https://mcp.socket.dev/","type":"http"})
|
|
28
31
|
[](https://cursor.com/en/install-mcp?name=socket-mcp&config=eyJ0eXBlIjoiaHR0cCIsInVybCI6Imh0dHBzOi8vbWNwLnNvY2tldC5kZXYvIn0%3D)
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
<details><summary><b>Manual Installation Instructions & more MCP Clients</b></summary>
|
|
32
|
-
|
|
33
|
-
<details><summary><b>Install in Claude Desktop or Claude Code</b></summary>
|
|
33
|
+
<details><summary><b>Manual install — Claude Desktop / Claude Code</b></summary>
|
|
34
34
|
|
|
35
35
|
> [!NOTE]
|
|
36
36
|
> Custom integrations are not available to all paid versions of Claude. Check [here](https://support.anthropic.com/en/articles/11175166-about-custom-integrations-using-remote-mcp) for more information.
|
|
37
37
|
|
|
38
|
-
To use the public Socket MCP server with Claude Desktop:
|
|
39
|
-
|
|
40
38
|
1. In Claude Desktop, go to Settings > Developer > Edit Config.
|
|
41
|
-
|
|
42
39
|
2. Add the Socket MCP server configuration:
|
|
43
40
|
|
|
44
41
|
```json
|
|
@@ -53,29 +50,24 @@ To use the public Socket MCP server with Claude Desktop:
|
|
|
53
50
|
```
|
|
54
51
|
|
|
55
52
|
3. Save the configuration and restart Claude Desktop.
|
|
53
|
+
4. Now you can ask Claude "Check the security score for express version 4.18.2".
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
The process is similar for Claude Code. See the [Claude Code documentation](https://docs.anthropic.com/en/docs/claude-code/mcp) for more details. Here's an example command to add the Socket MCP server:
|
|
55
|
+
For Claude Code:
|
|
60
56
|
|
|
61
|
-
```
|
|
57
|
+
```sh
|
|
62
58
|
claude mcp add --transport http socket-mcp https://mcp.socket.dev/
|
|
63
59
|
```
|
|
64
60
|
|
|
65
61
|
</details>
|
|
66
62
|
|
|
67
|
-
<details><summary><b>
|
|
63
|
+
<details><summary><b>Manual install — VS Code</b></summary>
|
|
68
64
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
```bash
|
|
65
|
+
```sh
|
|
72
66
|
# For VS Code with GitHub Copilot
|
|
73
|
-
code --add-mcp '{"name":"socket-mcp","type":"http","url":"https://mcp.socket.dev/}'
|
|
67
|
+
code --add-mcp '{"name":"socket-mcp","type":"http","url":"https://mcp.socket.dev/"}'
|
|
74
68
|
```
|
|
75
69
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Alternatively, you can manually add it to your VS Code MCP configuration in `.vscode/mcp.json`:
|
|
70
|
+
Or add to `.vscode/mcp.json`:
|
|
79
71
|
|
|
80
72
|
```json
|
|
81
73
|
{
|
|
@@ -90,9 +82,9 @@ Alternatively, you can manually add it to your VS Code MCP configuration in `.vs
|
|
|
90
82
|
|
|
91
83
|
</details>
|
|
92
84
|
|
|
93
|
-
<details><summary><b>
|
|
85
|
+
<details><summary><b>Manual install — Cursor</b></summary>
|
|
94
86
|
|
|
95
|
-
|
|
87
|
+
`Cursor Settings` → `MCP` → `Add new MCP Server`. Name `socket-mcp`, `http` type, URL `https://mcp.socket.dev/`.
|
|
96
88
|
|
|
97
89
|
```json
|
|
98
90
|
{
|
|
@@ -107,274 +99,319 @@ Go to `Cursor Settings` -> `MCP` -> `Add new MCP Server`. Name it "socket-mcp",
|
|
|
107
99
|
|
|
108
100
|
</details>
|
|
109
101
|
|
|
110
|
-
<details><summary><b>
|
|
102
|
+
<details><summary><b>Manual install — Windsurf</b></summary>
|
|
111
103
|
|
|
112
104
|
> [!WARNING]
|
|
113
|
-
> Windsurf does not support `http` type MCP servers yet. Use the
|
|
114
|
-
|
|
115
|
-
To use the Socket MCP server in Windsurf:
|
|
116
|
-
|
|
117
|
-
1. Open Windsurf Settings
|
|
118
|
-
2. Navigate to MCP Servers section
|
|
119
|
-
3. Add a new server with the following configuration:
|
|
105
|
+
> Windsurf does not support `http` type MCP servers yet. Use the stdio configuration in Option 2 below.
|
|
120
106
|
|
|
121
107
|
```json
|
|
122
108
|
{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
109
|
+
"mcpServers": {
|
|
110
|
+
"socket-mcp": {
|
|
111
|
+
"serverUrl": "https://mcp.socket.dev/mcp"
|
|
127
112
|
}
|
|
113
|
+
}
|
|
128
114
|
}
|
|
129
115
|
```
|
|
130
116
|
|
|
131
|
-
4. Save the configuration and restart Windsurf if needed.
|
|
132
|
-
|
|
133
117
|
</details>
|
|
134
118
|
|
|
135
|
-
|
|
119
|
+
<details><summary><b>Manual install — Factory</b></summary>
|
|
136
120
|
|
|
137
|
-
|
|
121
|
+
[Factory](https://factory.ai) is an AI-powered software engineering platform. Install the Socket MCP server with the Factory CLI:
|
|
138
122
|
|
|
139
|
-
|
|
123
|
+
```bash
|
|
124
|
+
droid mcp add socket https://mcp.socket.dev/ --type http
|
|
125
|
+
```
|
|
140
126
|
|
|
141
|
-
|
|
127
|
+
To self-host with an API key instead, see Option 2 below and register the stdio command with `droid mcp add`.
|
|
142
128
|
|
|
143
|
-
|
|
129
|
+
Alternatively, type `/mcp` within the Factory droid to manage MCP servers from an interactive UI. Learn more in the [Factory MCP documentation](https://docs.factory.ai/cli/configuration/mcp).
|
|
144
130
|
|
|
145
|
-
|
|
131
|
+
</details>
|
|
146
132
|
|
|
147
|
-
|
|
133
|
+
### Option 2: Self-host the Socket MCP server
|
|
148
134
|
|
|
149
|
-
|
|
135
|
+
To run your own instance, create an API key first (only the `packages:list` permission scope is needed; see [creating-and-managing-api-tokens](https://docs.socket.dev/reference/creating-and-managing-api-tokens)).
|
|
150
136
|
|
|
151
|
-
|
|
152
|
-
[](https://cursor.com/en/install-mcp?name=socket-mcp&config=eyJjb21tYW5kIjoibnB4IEBzb2NrZXRzZWN1cml0eS9tY3BAbGF0ZXN0IiwiZW52Ijp7IlNPQ0tFVF9BUElfS0VZIjoieW91ci1hcGkta2V5LWhlcmUifX0%3D)
|
|
137
|
+
<details><summary><b>Option 2a — Stdio mode (default)</b></summary>
|
|
153
138
|
|
|
154
|
-
Claude Code
|
|
139
|
+
Claude Code:
|
|
155
140
|
|
|
156
|
-
```
|
|
157
|
-
claude mcp add socket-mcp -e
|
|
141
|
+
```sh
|
|
142
|
+
claude mcp add socket-mcp -e SOCKET_API_TOKEN="your-api-token-here" -- npx -y @socketsecurity/mcp@latest # socket-hook: allow npx
|
|
158
143
|
```
|
|
159
|
-
|
|
144
|
+
|
|
145
|
+
Most other MCP clients:
|
|
160
146
|
|
|
161
147
|
```json
|
|
162
148
|
{
|
|
163
149
|
"mcpServers": {
|
|
164
150
|
"socket-mcp": {
|
|
165
|
-
"command": "npx",
|
|
151
|
+
"command": "npx", // socket-hook: allow npx
|
|
166
152
|
"args": ["@socketsecurity/mcp@latest"],
|
|
167
153
|
"env": {
|
|
168
|
-
"
|
|
154
|
+
"SOCKET_API_TOKEN": "your-api-token-here"
|
|
169
155
|
}
|
|
170
156
|
}
|
|
171
157
|
}
|
|
172
158
|
}
|
|
173
159
|
```
|
|
174
160
|
|
|
175
|
-
|
|
161
|
+
</details>
|
|
162
|
+
|
|
163
|
+
<details><summary><b>Option 2b — HTTP mode</b></summary>
|
|
164
|
+
|
|
165
|
+
Run the server in HTTP mode using npx:
|
|
166
|
+
|
|
167
|
+
```sh
|
|
168
|
+
MCP_HTTP_MODE=true SOCKET_API_TOKEN=your-api-token npx @socketsecurity/mcp@latest --http # socket-hook: allow npx
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Environment variables for HTTP mode:
|
|
172
|
+
|
|
173
|
+
| Variable | Required | Default | Description |
|
|
174
|
+
| ------------------------------------------ | ------------------------------------------------------------ | ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
175
|
+
| `SOCKET_API_TOKEN` | Required unless OAuth is enabled | None | Socket API token used for outbound API calls. Legacy aliases (`SOCKET_API_KEY`, `SOCKET_CLI_API_TOKEN`, `SOCKET_CLI_API_KEY`, `SOCKET_SECURITY_API_TOKEN`, `SOCKET_SECURITY_API_KEY`) are accepted via the fleet's `getSocketApiToken()` helper. If unset in OAuth-enabled HTTP mode, the validated incoming bearer token is forwarded upstream instead. |
|
|
176
|
+
| `SOCKET_OAUTH_ISSUER` | Set together with the two introspection vars to enable OAuth | None | OAuth issuer URL used for metadata discovery and incoming bearer-token validation. |
|
|
177
|
+
| `SOCKET_OAUTH_INTROSPECTION_CLIENT_ID` | With OAuth | None | Client ID used for token introspection. |
|
|
178
|
+
| `SOCKET_OAUTH_INTROSPECTION_CLIENT_SECRET` | With OAuth | None | Client secret used for token introspection. |
|
|
179
|
+
| `SOCKET_OAUTH_REQUIRED_SCOPES` | No | `packages:list` | Space-delimited scopes required on incoming access tokens. |
|
|
180
|
+
| `SOCKET_API_URL` | No | Production Socket API URL, or localhost when `SOCKET_DEBUG=true` | Override the upstream Socket API endpoint. Useful for local development and testing. |
|
|
181
|
+
| `SOCKET_DEBUG` | No | `false` | Switches the default upstream Socket API endpoint to localhost when `SOCKET_API_URL` is unset. |
|
|
182
|
+
| `TRUST_PROXY` | No | `false` | When `true`, trust `X-Forwarded-Host` and `X-Forwarded-Proto` when building OAuth metadata URLs. Enable only behind a trusted reverse proxy that rewrites these headers. |
|
|
183
|
+
| `MCP_PORT` | HTTP mode only | `3000` | Port to bind the HTTP server to. |
|
|
184
|
+
|
|
185
|
+
`SOCKET_API_URL` and `SOCKET_DEBUG` also apply in stdio mode.
|
|
186
|
+
|
|
187
|
+
To enable OAuth-backed auth for incoming MCP requests:
|
|
188
|
+
|
|
189
|
+
```sh
|
|
190
|
+
MCP_HTTP_MODE=true \
|
|
191
|
+
SOCKET_OAUTH_ISSUER=https://issuer.example.com \
|
|
192
|
+
SOCKET_OAUTH_INTROSPECTION_CLIENT_ID=your-client-id \
|
|
193
|
+
SOCKET_OAUTH_INTROSPECTION_CLIENT_SECRET=your-client-secret \
|
|
194
|
+
npx @socketsecurity/mcp@latest --http # socket-hook: allow npx
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Add `TRUST_PROXY=true` only when the server is deployed behind a trusted reverse proxy or load balancer that normalizes the forwarded host and protocol headers.
|
|
198
|
+
|
|
199
|
+
Configure your MCP client to connect to the HTTP server:
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"mcpServers": {
|
|
204
|
+
"socket-mcp": {
|
|
205
|
+
"type": "http",
|
|
206
|
+
"url": "http://localhost:3000"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
</details>
|
|
213
|
+
|
|
214
|
+
## Usage
|
|
176
215
|
|
|
216
|
+
Once installed, ask your AI assistant questions like:
|
|
177
217
|
|
|
178
|
-
|
|
218
|
+
- "Check the security score for express version 4.18.2"
|
|
219
|
+
- "Analyze the security of my package.json dependencies"
|
|
220
|
+
- "What are the vulnerability scores for react, lodash, and axios?"
|
|
179
221
|
|
|
180
|
-
|
|
181
|
-
```bash
|
|
182
|
-
MCP_HTTP_MODE=true SOCKET_API_KEY=your-api-key npx @socketsecurity/mcp@latest --http
|
|
183
|
-
```
|
|
222
|
+
### Tools exposed
|
|
184
223
|
|
|
185
|
-
|
|
186
|
-
```json
|
|
187
|
-
{
|
|
188
|
-
"mcpServers": {
|
|
189
|
-
"socket-mcp": {
|
|
190
|
-
"type": "http",
|
|
191
|
-
"url": "http://localhost:3000"
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
```
|
|
224
|
+
#### depscore
|
|
196
225
|
|
|
197
|
-
|
|
226
|
+
Query the Socket API for dependency scoring information. Returns supply chain, quality, maintenance, vulnerability, and license scores per package.
|
|
198
227
|
|
|
199
|
-
|
|
228
|
+
| Parameter | Type | Required | Default | Description |
|
|
229
|
+
| ---------------------- | ------ | -------- | ----------- | -------------------------------------------------- |
|
|
230
|
+
| `packages` | Array | ✅ Yes | - | Array of package objects to analyze |
|
|
231
|
+
| `packages[].ecosystem` | String | No | `"npm"` | Package ecosystem. See Supported ecosystems below. |
|
|
232
|
+
| `packages[].depname` | String | ✅ Yes | - | Name of the dependency/package |
|
|
233
|
+
| `packages[].version` | String | No | `"unknown"` | Version of the dependency |
|
|
200
234
|
|
|
201
|
-
|
|
235
|
+
**Supported ecosystems**
|
|
202
236
|
|
|
203
|
-
|
|
237
|
+
Based on [Socket's language support](https://docs.socket.dev/docs/language-support). The `ecosystem` parameter maps to PURL types:
|
|
204
238
|
|
|
205
|
-
|
|
|
206
|
-
|
|
207
|
-
|
|
|
208
|
-
|
|
|
209
|
-
| `
|
|
210
|
-
|
|
|
239
|
+
| Ecosystem | PURL type | Package managers | Maturity |
|
|
240
|
+
| ----------------------- | ---------- | ------------------------- | --------------------------------------------------- |
|
|
241
|
+
| JavaScript & TypeScript | `npm` | npm, yarn, pnpm, Bun, VLT | GA |
|
|
242
|
+
| Python | `pypi` | uv, pip, Poetry, Anaconda | GA |
|
|
243
|
+
| Go | `golang` | Go Modules | GA |
|
|
244
|
+
| Java / Scala / Kotlin | `maven` | Maven, Gradle, sbt | GA |
|
|
245
|
+
| Ruby | `gem` | Bundler | GA |
|
|
246
|
+
| .NET (C#, F#, VB) | `nuget` | NuGet | GA |
|
|
247
|
+
| Rust | `cargo` | cargo | GA |
|
|
248
|
+
| PHP | `composer` | Composer | Experimental |
|
|
249
|
+
| GitHub Actions | `actions` | GitHub Actions workflows | Experimental (workflow scanning, not package-level) |
|
|
211
250
|
|
|
212
|
-
|
|
251
|
+
Example request:
|
|
213
252
|
|
|
214
253
|
```json
|
|
215
254
|
{
|
|
216
255
|
"packages": [
|
|
217
|
-
{
|
|
218
|
-
|
|
219
|
-
"depname": "express",
|
|
220
|
-
"version": "4.18.2"
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
"ecosystem": "pypi",
|
|
224
|
-
"depname": "fastapi",
|
|
225
|
-
"version": "0.100.0"
|
|
226
|
-
}
|
|
256
|
+
{ "ecosystem": "npm", "depname": "express", "version": "4.18.2" },
|
|
257
|
+
{ "ecosystem": "pypi", "depname": "fastapi", "version": "0.100.0" }
|
|
227
258
|
]
|
|
228
259
|
}
|
|
229
260
|
```
|
|
230
261
|
|
|
231
|
-
|
|
262
|
+
Sample response:
|
|
263
|
+
|
|
232
264
|
```
|
|
233
265
|
pkg:npm/express@4.18.2: supply_chain: 1.0, quality: 0.9, maintenance: 1.0, vulnerability: 1.0, license: 1.0
|
|
266
|
+
Report: https://socket.dev/npm/package/express
|
|
234
267
|
pkg:pypi/fastapi@0.100.0: supply_chain: 1.0, quality: 0.95, maintenance: 0.98, vulnerability: 1.0, license: 1.0
|
|
268
|
+
Report: https://socket.dev/pypi/package/fastapi
|
|
235
269
|
```
|
|
236
270
|
|
|
237
|
-
###
|
|
238
|
-
|
|
239
|
-
1. **Ask your AI assistant** to check dependencies:
|
|
240
|
-
- "Check the security score for express version 4.18.2"
|
|
241
|
-
- "Analyze the security of my package.json dependencies"
|
|
242
|
-
- "What are the vulnerability scores for react, lodash, and axios?"
|
|
243
|
-
|
|
244
|
-
2. **Get comprehensive security insights** including supply chain, quality, maintenance, vulnerability, and license scores.
|
|
245
|
-
|
|
246
|
-
### Adjust tool usage with custom rules
|
|
247
|
-
|
|
248
|
-
You can further customize how the Socket MCP server interacts with your AI assistant by modifying your client rules. The rules are usually a markdown file and its location depends on the AI assistant you are using.
|
|
271
|
+
### Adjusting tool usage via client rules
|
|
249
272
|
|
|
250
|
-
|
|
251
|
-
|---|---|
|
|
252
|
-
| Claude Desktop/Code | `CLAUDE.md` |
|
|
253
|
-
| VSCode Copilot | `.github/copilot-instructions.md` |
|
|
254
|
-
| Cursor | `.cursor/rules` |
|
|
273
|
+
You can customize how the MCP server interacts with your AI assistant by editing your client's rules file:
|
|
255
274
|
|
|
275
|
+
| MCP Client | Rules File Location |
|
|
276
|
+
| ------------------- | --------------------------------- |
|
|
277
|
+
| Claude Desktop/Code | `CLAUDE.md` |
|
|
278
|
+
| VSCode Copilot | `.github/copilot-instructions.md` |
|
|
279
|
+
| Cursor | `.cursor/rules` |
|
|
256
280
|
|
|
257
|
-
|
|
281
|
+
Example rule:
|
|
258
282
|
|
|
259
283
|
```md
|
|
260
|
-
Always check dependency scores with the depscore tool when you add a new dependency. If the score is low, consider using an alternative library or writing the code yourself.
|
|
284
|
+
Always check dependency scores with the depscore tool when you add a new dependency. If the score is low, consider using an alternative library or writing the code yourself.
|
|
261
285
|
```
|
|
262
286
|
|
|
263
|
-
|
|
287
|
+
## Claude Code Hook (Optional)
|
|
264
288
|
|
|
289
|
+
The repo ships an optional [Claude Code hook](https://code.claude.com/docs/en/hooks) that blocks high-risk packages before installation. When Claude Code runs an install command, the hook queries the public Socket MCP server at `https://mcp.socket.dev/` and denies the install when the package's supply chain score is below `20` (known malware, typosquats, high-risk supply chain signals). No API key, no CLI, no registration — copy the file and wire it up.
|
|
265
290
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
### For End Users
|
|
269
|
-
|
|
270
|
-
For most users, we recommend using either:
|
|
271
|
-
1. **Public server**: `https://mcp.socket.dev/` (no setup required)
|
|
272
|
-
2. **NPX command**: `npx @socketsecurity/mcp@latest` (always latest version)
|
|
291
|
+
Supported ecosystems and package managers:
|
|
273
292
|
|
|
274
|
-
|
|
293
|
+
| Ecosystem | Commands |
|
|
294
|
+
| --------- | ----------------------------------------------------------------------------------------- |
|
|
295
|
+
| npm | `npm install`, `npm i`, `npm add`, `yarn add`, `pnpm add`, `bun add` |
|
|
296
|
+
| PyPI | `pip install`, `pip3 install`, `uv add`, `uv pip install`, `poetry add`, `pipenv install` |
|
|
297
|
+
| Cargo | `cargo add`, `cargo install` |
|
|
298
|
+
| RubyGems | `gem install`, `bundle add` |
|
|
299
|
+
| Go | `go get`, `go install` |
|
|
300
|
+
| NuGet | `dotnet add package`, `nuget install` |
|
|
275
301
|
|
|
276
|
-
|
|
302
|
+
### Setup
|
|
277
303
|
|
|
278
|
-
|
|
304
|
+
**Prerequisites:** Node.js 22+.
|
|
279
305
|
|
|
280
|
-
|
|
306
|
+
1. Copy the whole `socket-gate` directory into your hooks folder. The bundled
|
|
307
|
+
`socket-gate.cjs` is self-contained, so it runs without any dependencies
|
|
308
|
+
beside it. From a checkout, run `pnpm run build` first to produce it; from a
|
|
309
|
+
published install, copy from `node_modules/@socketsecurity/mcp/`:
|
|
281
310
|
|
|
282
311
|
```bash
|
|
283
|
-
|
|
312
|
+
mkdir -p ~/.claude/hooks
|
|
313
|
+
cp -R hooks/socket-gate ~/.claude/hooks/
|
|
284
314
|
```
|
|
285
315
|
|
|
286
|
-
|
|
316
|
+
2. Add to `~/.claude/settings.json`:
|
|
317
|
+
|
|
287
318
|
```json
|
|
288
319
|
{
|
|
289
|
-
"
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
320
|
+
"hooks": {
|
|
321
|
+
"PreToolUse": [
|
|
322
|
+
{
|
|
323
|
+
"matcher": "Bash",
|
|
324
|
+
"hooks": [
|
|
325
|
+
{
|
|
326
|
+
"type": "command",
|
|
327
|
+
"command": "node ~/.claude/hooks/socket-gate/socket-gate.cjs"
|
|
328
|
+
}
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
}
|
|
293
333
|
}
|
|
294
334
|
```
|
|
295
335
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
- Docker health checks
|
|
299
|
-
- Load balancer health monitoring
|
|
300
|
-
- General service monitoring
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
#### Prerequisites
|
|
336
|
+
See [`hooks/socket-gate/README.md`](hooks/socket-gate/README.md) for the full
|
|
337
|
+
reference.
|
|
304
338
|
|
|
305
|
-
|
|
306
|
-
- npm or yarn
|
|
339
|
+
### How it works
|
|
307
340
|
|
|
308
|
-
|
|
341
|
+
The hook denies installation when `supplyChain < 20`, allows it otherwise — e.g. `express`/`lodash`/`react` (75–97) allow, `browserlist` (typosquat of `browserslist`, 15) and confirmed malware (0) block. Network, timeout, or parse errors all fail open, so a Socket outage will not block legitimate work.
|
|
309
342
|
|
|
310
|
-
|
|
343
|
+
### Limitations
|
|
311
344
|
|
|
312
|
-
|
|
313
|
-
git clone https://github.com/SocketDev/socket-mcp.git
|
|
314
|
-
cd socket-mcp
|
|
315
|
-
npm install
|
|
316
|
-
```
|
|
345
|
+
A best-effort guardrail, not a complete defense. Known gaps:
|
|
317
346
|
|
|
318
|
-
|
|
347
|
+
- **Manifest edits + lockfile installs.** If Claude edits a manifest directly (`package.json`, `requirements.txt`, `Cargo.toml`, `Gemfile`, `go.mod`, `*.csproj`) then runs a bare install (`npm install`, `pip install -r requirements.txt`, `cargo build`, `bundle install`, `go mod tidy`, `dotnet restore`), there is no package name on the command line to check.
|
|
348
|
+
- **Package-manager invocations only.** Direct downloads (`curl | sh`, `wget`), post-install scripts of already-accepted packages, and transitive dependencies are not re-checked.
|
|
349
|
+
- **Indirect Claude paths.** Sub-agents, MCP tools that shell out, and non-`Bash` tool calls are not covered unless the `matcher` is broadened.
|
|
319
350
|
|
|
320
|
-
|
|
321
|
-
If you are on Node.js 22, run with `node --experimental-strip-types index.ts`.
|
|
322
|
-
On any later versions of Node.js, you can simply run `node index.ts`.
|
|
323
|
-
In either version you can also run the npm run scripts which include the correct flags.
|
|
351
|
+
Inspired by [Jimmy Vo's dependency hook](https://blog.jimmyvo.com/posts/claudes-dependency-hook/).
|
|
324
352
|
|
|
325
|
-
|
|
353
|
+
## Development
|
|
326
354
|
|
|
327
|
-
|
|
355
|
+
<details>
|
|
356
|
+
<summary>Contributor commands</summary>
|
|
328
357
|
|
|
329
|
-
```
|
|
358
|
+
```sh
|
|
359
|
+
git clone https://github.com/SocketDev/socket-mcp.git
|
|
360
|
+
cd socket-mcp
|
|
361
|
+
npm install
|
|
330
362
|
npm run build
|
|
331
363
|
```
|
|
332
364
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
To run the Socket MCP server from source:
|
|
365
|
+
Run from source (stdio mode):
|
|
336
366
|
|
|
337
|
-
```
|
|
338
|
-
export
|
|
367
|
+
```sh
|
|
368
|
+
export SOCKET_API_TOKEN=your_api_token_here
|
|
339
369
|
node --experimental-strip-types index.ts
|
|
340
370
|
```
|
|
341
371
|
|
|
342
372
|
Or in HTTP mode:
|
|
343
373
|
|
|
344
|
-
```
|
|
345
|
-
MCP_HTTP_MODE=true
|
|
374
|
+
```sh
|
|
375
|
+
MCP_HTTP_MODE=true SOCKET_API_TOKEN=your_api_token_here node --experimental-strip-types index.ts --http
|
|
346
376
|
```
|
|
347
377
|
|
|
348
|
-
|
|
378
|
+
### Health check endpoint
|
|
349
379
|
|
|
350
|
-
|
|
380
|
+
When running in HTTP mode, `GET /health` returns:
|
|
351
381
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
-
|
|
382
|
+
```json
|
|
383
|
+
{
|
|
384
|
+
"status": "healthy",
|
|
385
|
+
"service": "socket-mcp",
|
|
386
|
+
"version": "0.0.3",
|
|
387
|
+
"timestamp": "2025-06-17T20:45:22.059Z"
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
Suitable for Kubernetes liveness/readiness probes, Docker health checks, load balancers.
|
|
392
|
+
|
|
393
|
+
### Troubleshooting
|
|
356
394
|
|
|
357
|
-
**Q:
|
|
358
|
-
- Ensure you have Node.js v16+ installed
|
|
359
|
-
- Check that your `SOCKET_API_KEY` environment variable is set
|
|
360
|
-
- Verify the API key has `packages:list` permission
|
|
395
|
+
**Q: The public server isn't responding** — Check the URL `https://mcp.socket.dev/`, verify your MCP client configuration, restart your MCP client.
|
|
361
396
|
|
|
362
|
-
**Q:
|
|
363
|
-
- Double-check your Socket API key is valid
|
|
364
|
-
- Ensure the key has the required `packages:list` scope
|
|
365
|
-
- Try regenerating your API key from the Socket dashboard
|
|
397
|
+
**Q: Local server fails to start** — Ensure Node.js v16+ is installed, check `SOCKET_API_TOKEN` is set, verify the API token has `packages:list` permission.
|
|
366
398
|
|
|
367
|
-
**Q:
|
|
368
|
-
- Restart your MCP client after configuration changes
|
|
369
|
-
- Verify the server configuration is saved correctly
|
|
370
|
-
- Check that the MCP server is running (for local deployments)
|
|
399
|
+
**Q: Getting authentication errors with local server** — Double-check your API key is valid, ensure `packages:list` scope, regenerate if needed.
|
|
371
400
|
|
|
372
|
-
|
|
401
|
+
**Q: AI assistant can't find the depscore tool** — Restart your MCP client after configuration changes, verify config is saved, check the server is running.
|
|
402
|
+
|
|
403
|
+
### Getting help
|
|
373
404
|
|
|
374
405
|
- 📖 [Socket Documentation](https://docs.socket.dev)
|
|
375
406
|
- 🐛 [Report Issues](https://github.com/SocketDev/socket-mcp/issues)
|
|
376
407
|
- 💬 [Community Support](https://github.com/SocketDev/socket-mcp/discussions)
|
|
377
408
|
|
|
409
|
+
</details>
|
|
410
|
+
|
|
411
|
+
## License
|
|
412
|
+
|
|
413
|
+
MIT
|
|
414
|
+
|
|
378
415
|
<br/>
|
|
379
416
|
<div align="center">
|
|
380
417
|
<picture>
|