Skip to content

Commit fc81cfb

Browse files
committed
Convert the project to use Node.js type stripping
1 parent fbd5d24 commit fc81cfb

21 files changed

+2802
-1349
lines changed

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
**/.env*
2+
**/.git
3+
**/.idea
4+
**/.config
5+
**/.npm
6+
**/.github
7+
**/.DS_Store
8+
**/.gitignore
9+
**/.scannerwork
10+
**/.editorconfig
11+
**/certs
12+
**/nodemon.json
13+
**/node_modules
14+
**/npm-debug.log
15+
**/public
16+
**/.dtx

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
2+
version: 2
3+
updates:
4+
- package-ecosystem: "npm"
5+
directory: "/"
6+
schedule:
7+
interval: "daily"
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"

.github/workflows/provenance.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
12
name: Publish Packages to npm
23

34
on:
@@ -50,7 +51,7 @@ jobs:
5051
release_name: Release v${{ steps.package-version.outputs.version }}
5152
body: |
5253
Release of @socketsecurity/mcp v${{ steps.package-version.outputs.version }}
53-
54+
5455
This release has been published to npm with provenance.
5556
draft: false
5657
prerelease: false

.github/workflows/test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
name: tests
3+
4+
on: [pull_request, push]
5+
6+
env:
7+
FORCE_COLOR: 1
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest]
17+
node: ['lts/*']
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Use Node.js ${{ matrix.node }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node }}
25+
- run: npm i
26+
- run: npm test --color=always
27+
env:
28+
SOCKET_API_KEY: ${{ secrets.SOCKET_API_KEY }}

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,15 @@ build/
55
.claude/
66
.DS_Store
77
socket-mcp.dxt
8+
coverage
9+
*.tgz
10+
11+
# Generated types
12+
13+
*.d.ts
14+
*.d.ts.map
15+
16+
# Generated js
17+
18+
*.js
19+
!*.config.js

.npmignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
sandbox.js
3+
.nyc_output
4+
package-lock.json
5+
public
6+
coverage
7+
.tap
8+
.nova
9+
.dtx

DEBUG.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ The `mock-client` directory contains debug clients for testing the Socket MCP se
44

55
## Prerequisites
66

7-
1. Build the project:
7+
1. Ensure you are running Node 22 or later:
88

99
```bash
10-
npm run build
10+
node --version
11+
v22.17.0
1112
```
1213

1314
2. Set your Socket API key:
@@ -23,7 +24,7 @@ The `mock-client` directory contains debug clients for testing the Socket MCP se
2324
Direct stdio communication using JSON-RPC protocol:
2425

2526
```bash
26-
npm run debug:stdio
27+
npm run debug-stdio
2728
```
2829

2930
This client:
@@ -37,7 +38,7 @@ This client:
3738
Uses the official MCP SDK client library:
3839

3940
```bash
40-
npm run debug:sdk
41+
npm run debug-sdk
4142
```
4243

4344
This client:
@@ -52,10 +53,10 @@ Tests the HTTP/SSE transport mode:
5253

5354
```bash
5455
# First, start the server in HTTP mode:
55-
npm run server:http
56+
npm run server-http
5657

5758
# In another terminal:
58-
npm run debug:http
59+
npm run debug-http
5960
```
6061

6162
This client:
@@ -115,7 +116,7 @@ All clients test the following scenarios:
115116
To test against a local Socket API:
116117

117118
```bash
118-
# Edit src/index.ts and change SOCKET_API_URL
119+
# Edit index.ts and change SOCKET_API_URL
119120
# Then rebuild and test
120121
```
121122

Dockerfile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ COPY *.json ./
99
RUN npm install --ignore-scripts
1010

1111
# Copy all source code
12-
COPY src ./src
13-
14-
# Build the application
15-
RUN npm run build
12+
COPY . .
1613

1714
# Environment variables for configuration
1815
ENV MCP_PORT="3000"
@@ -21,4 +18,4 @@ ENV MCP_PORT="3000"
2118
EXPOSE ${MCP_PORT}
2219

2320
# Command to run the server
24-
CMD [ "node", "build/index.js" , "--http"]
21+
CMD [ "node", "--experimental-strip-types", "index.ts" , "--http"]

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Alternatively, you can manually add it to your VS Code MCP configuration in `.vs
8181
{
8282
"servers": {
8383
"socket-mcp": {
84-
"type": "http",
84+
"type": "http",
8585
"url": "https://mcp.socket.dev/"
8686
}
8787
}
@@ -148,7 +148,7 @@ For local deployment, you have two options:
148148

149149
Click a button below to install the self-hosted stdio server in your favorite AI assistant.
150150

151-
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Socket_MCP-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect/mcp/install?name=socket-mcp&config={"command":"npx","args":["@socketsecurity/mcp@latest"],"type":"stdio"})
151+
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Socket_MCP-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect/mcp/install?name=socket-mcp&config={"command":"npx","args":["@socketsecurity/mcp@latest"],"type":"stdio"})
152152
[![Install in Cursor (stdio)](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/install-mcp?name=socket-mcp-stdio&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyJAc29ja2V0c2VjdXJpdHkvbWNwQGxhdGVzdCJdLCJlbnYiOnsiU09DS0VUX0FQSV9LRVkiOiJ5b3VyLWFwaS1rZXktaGVyZSJ9fQ==)
153153

154154
Claude Code (stdio mode) can be set up with the following command:
@@ -220,7 +220,7 @@ The `depscore` tool allows AI assistants to query the Socket API for dependency
220220
"version": "4.18.2"
221221
},
222222
{
223-
"ecosystem": "pypi",
223+
"ecosystem": "pypi",
224224
"depname": "fastapi",
225225
"version": "0.100.0"
226226
}
@@ -241,7 +241,7 @@ pkg:pypi/[email protected]: supply_chain: 1.0, quality: 0.95, maintenance: 0.98, v
241241
- "Analyze the security of my package.json dependencies"
242242
- "What are the vulnerability scores for react, lodash, and axios?"
243243

244-
2. **Get comprehensive security insights** including supply chain, quality, maintenance, vulnerability, and license scores.
244+
2. **Get comprehensive security insights** including supply chain, quality, maintenance, vulnerability, and license scores.
245245

246246
### Adjust tool usage with custom rules
247247

@@ -317,7 +317,14 @@ npm install
317317

318318
#### Build
319319

320-
To build the project:
320+
This project is a directly runnable Node.js project using [Type stripping](https://nodejs.org/docs/latest/api/typescript.html).
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.
324+
325+
The js files will automatically be build when running `npm publish`, and cleaned up afterwards with `npm run clean`.
326+
327+
If you want to preview the build you can run:
321328

322329
```bash
323330
npm run build
@@ -329,13 +336,13 @@ To run the Socket MCP server from source:
329336

330337
```bash
331338
export SOCKET_API_KEY=your_api_key_here
332-
node build/index.js
339+
node --experimental-strip-types index.ts
333340
```
334341

335342
Or in HTTP mode:
336343

337344
```bash
338-
MCP_HTTP_MODE=true SOCKET_API_KEY=your_api_key_here node build/index.js --http
345+
MCP_HTTP_MODE=true SOCKET_API_KEY=your_api_key_here node --experimental-strip-types index.ts --http
339346
```
340347

341348
## 🔧 Troubleshooting
@@ -358,7 +365,7 @@ MCP_HTTP_MODE=true SOCKET_API_KEY=your_api_key_here node build/index.js --http
358365
- Try regenerating your API key from the Socket dashboard
359366

360367
**Q: AI assistant can't find the depscore tool**
361-
- Restart your MCP client after configuration changes
368+
- Restart your MCP client after configuration changes
362369
- Verify the server configuration is saved correctly
363370
- Check that the MCP server is running (for local deployments)
364371

@@ -367,4 +374,3 @@ MCP_HTTP_MODE=true SOCKET_API_KEY=your_api_key_here node build/index.js --http
367374
- 📖 [Socket Documentation](https://docs.socket.dev)
368375
- 🐛 [Report Issues](https://github.com/SocketDev/socket-mcp/issues)
369376
- 💬 [Community Support](https://github.com/SocketDev/socket-mcp/discussions)
370-

0 commit comments

Comments
 (0)