diff --git a/.github/workflows/dxt-pack.yaml b/.github/workflows/dxt-pack.yaml index 8ef674a..216058a 100644 --- a/.github/workflows/dxt-pack.yaml +++ b/.github/workflows/dxt-pack.yaml @@ -12,10 +12,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v5 - - name: Use Node.js 20 + - name: Use Node.js 22 uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '22' cache: 'npm' - name: Install dependencies diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..58da26c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +name: Publish to npm + +on: + push: + tags: + - 'v*' + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Publish to npm + run: npm publish --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..45d2cb8 --- /dev/null +++ b/.npmignore @@ -0,0 +1,27 @@ +# Source files (only dist/ should be published) +src/ +tsconfig.json +eslint.config.mjs + +# Development and build files +.github/ +scripts/ +node_modules/ +*.log + +# Test files +**/*.test.ts +**/*.test.js + +# Documentation (except README.md which is included) +DOCKER.md + +# Git and editor files +.git/ +.gitignore +.vscode/ +.cursor/ +.idea/ +*.swp +*.swo +*~ diff --git a/dist/package.json b/dist/package.json index db933b6..98d365c 100644 --- a/dist/package.json +++ b/dist/package.json @@ -1,16 +1,26 @@ { - "name": "postman-api-mcp", - "version": "1.2.1", + "name": "@postman/postman-mcp-server", + "version": "2.0.1", "description": "A simple MCP server to operate on the Postman API", - "main": "index.js", + "main": "dist/src/index.js", "type": "module", "scripts": { "start:stdio": "node dist/src/index.js", "build": "eslint --fix ./src && prettier --write \"src/**/*.ts\" && tsc", + "prepack": "npm run build && node scripts/sync-dist-pkg.mjs", "test": "vitest", "lint": "eslint", "lint:fix": "eslint --fix" }, + "bin": "dist/src/index.js", + "files": [ + "dist", + "README.md", + "LICENSE" + ], + "publishConfig": { + "access": "public" + }, "dependencies": { "@apidevtools/swagger-parser": "^11.0.0", "@modelcontextprotocol/sdk": "^1.17.0", diff --git a/dist/src/index.js b/dist/src/index.js old mode 100644 new mode 100755 index 9a53227..7682a26 --- a/dist/src/index.js +++ b/dist/src/index.js @@ -1,4 +1,4 @@ -#!/usr/bin/env tsx +#!/usr/bin/env node import dotenv from 'dotenv'; import { Server } from '@modelcontextprotocol/sdk/server/index.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; diff --git a/eslint.config.mjs b/eslint.config.mjs index 35975c5..7d86701 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -4,9 +4,9 @@ import unusedImports from "eslint-plugin-unused-imports"; import eslintConfigPrettier from 'eslint-config-prettier'; // Ensures ESLint doesn't conflict with Prettier export default tseslint.config( + { ignores: ['dist/**', '**/*.js'] }, { files: ['src/**/*.ts'], - ignores: ['**/*.js'] }, eslint.configs.recommended, tseslint.configs.recommended, diff --git a/package-lock.json b/package-lock.json index 86fe392..f8df328 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "postman-api-mcp", + "name": "@postman/postman-mcp-server", "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "postman-api-mcp", + "name": "@postman/postman-mcp-server", "version": "2.0.1", "license": "Apache-2.0", "dependencies": { @@ -15,6 +15,9 @@ "es-toolkit": "^1.37.2", "express": "^5.1.0" }, + "bin": { + "postman-mcp-server": "dist/src/index.js" + }, "devDependencies": { "@eslint/js": "^9.26.0", "@types/express": "^5.0.1", diff --git a/package.json b/package.json index 80772de..6643634 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,26 @@ { - "name": "postman-api-mcp", + "name": "@postman/postman-mcp-server", "version": "2.0.1", "description": "A simple MCP server to operate on the Postman API", - "main": "index.js", + "main": "dist/src/index.js", "type": "module", "scripts": { "start:stdio": "node dist/src/index.js", "build": "eslint --fix ./src && prettier --write \"src/**/*.ts\" && tsc", + "prepack": "npm run build && node scripts/sync-dist-pkg.mjs", "test": "vitest", "lint": "eslint", "lint:fix": "eslint --fix" }, + "bin": "dist/src/index.js", + "files": [ + "dist", + "README.md", + "LICENSE" + ], + "publishConfig": { + "access": "public" + }, "dependencies": { "@apidevtools/swagger-parser": "^11.0.0", "@modelcontextprotocol/sdk": "^1.17.0", diff --git a/src/index.ts b/src/index.ts index 3fe49e9..7524bcf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -#!/usr/bin/env tsx +#!/usr/bin/env node import dotenv from 'dotenv'; import { Server } from '@modelcontextprotocol/sdk/server/index.js'; diff --git a/src/tests/integration/direct.test.ts b/src/tests/integration/direct.test.ts index 11f1311..59bda46 100644 --- a/src/tests/integration/direct.test.ts +++ b/src/tests/integration/direct.test.ts @@ -84,7 +84,7 @@ describe('Postman MCP - Direct Integration Tests', () => { createdSpecIds = []; }); - describe('Workspace Workflow',{ timeout: 30000 }, () => { + describe('Workspace Workflow', { timeout: 30000 }, () => { it('should create, list, search, update, and delete a single workspace', async () => { const workspaceData = WorkspaceDataFactory.createWorkspace(); const workspaceId = await createWorkspace(workspaceData); @@ -126,7 +126,7 @@ describe('Postman MCP - Direct Integration Tests', () => { expect(WorkspaceDataFactory.validateResponse(verifyUpdateResult)).toBe(true); expect((verifyUpdateResult.content as any)[0].text).toContain(updatedName); }); - }, ); + }); describe('Environment Workflow', () => { it('should create, list, search, update, and delete a single environment', async () => { diff --git a/src/tests/integration/factories/dataFactory.ts b/src/tests/integration/factories/dataFactory.ts index 330453c..befb36b 100644 --- a/src/tests/integration/factories/dataFactory.ts +++ b/src/tests/integration/factories/dataFactory.ts @@ -151,7 +151,7 @@ export class SpecDataFactory extends TestDataFactory { return { path: 'index.yaml', content: - 'openapi: 3.0.0\ninfo:\n title: My API\n version: 1.0.0\npaths:\n /:\n get:\n summary: My Endpoint\n responses:\n \'200\':\n description: OK', + "openapi: 3.0.0\ninfo:\n title: My API\n version: 1.0.0\npaths:\n /:\n get:\n summary: My Endpoint\n responses:\n '200':\n description: OK", ...overrides, }; }