Skip to content

Commit 805b81e

Browse files
committed
ci: improve MCP publishing workflow and automate server.json updates
- Update publish workflow to trigger on Release completion - Add workflow_dispatch for manual execution and safety checks - Create update-server-json.js script to automate version and hash updates - Integrate server.json updates into semantic-release process - Include server.json in Git assets and GitHub release artifacts - Improve workflow reliability with frozen lockfile and better triggers
1 parent b9f661c commit 805b81e

File tree

4 files changed

+103
-29
lines changed

4 files changed

+103
-29
lines changed

.github/workflows/publish-mcp.yml

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,50 @@
1-
name: Publish MCP Server
1+
name: Publish to MCP Registry
22

33
on:
4+
workflow_run:
5+
workflows: ['Release']
6+
types: [completed]
7+
branches: [master]
8+
workflow_dispatch: # Support manual execution
49
push:
5-
tags:
6-
- 'v*.*.*'
10+
tags: ['v*'] # Also triggers on version tags like v1.0.0
711

812
permissions:
13+
id-token: write # Required for OIDC authentication
914
contents: read
10-
id-token: write
1115

1216
jobs:
1317
publish:
1418
runs-on: ubuntu-latest
19+
# Only run if the Release workflow succeeded or if manually triggered
20+
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' || github.event.workflow_run.conclusion == 'success' }}
1521

1622
steps:
1723
- name: Checkout code
1824
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
1927

2028
- name: Setup Node.js
2129
uses: actions/setup-node@v4
2230
with:
2331
node-version: '20'
24-
registry-url: 'https://registry.npmjs.org'
2532

2633
- name: Setup pnpm
2734
uses: pnpm/action-setup@v4
28-
with:
29-
version: 10.12.1
3035

3136
- name: Install dependencies
32-
run: pnpm install
37+
run: pnpm install --frozen-lockfile
3338

34-
- name: Run linter
39+
- name: Lint and format check
3540
run: pnpm run lint
3641

37-
- name: Build project
38-
run: pnpm run build
39-
40-
- name: Publish to npm
41-
run: pnpm publish --no-git-checks
42-
env:
43-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44-
45-
- name: Install MCP Publisher CLI
46-
run: npm install -g @modelcontextprotocol/publisher
42+
- name: Install MCP Publisher
43+
run: |
44+
curl -L "https://github.com/modelcontextprotocol/registry/releases/download/v1.0.0/mcp-publisher_1.0.0_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher
4745
4846
- name: Login to MCP Registry
49-
run: mcp-publisher login github-oidc
47+
run: ./mcp-publisher login github-oidc
5048

5149
- name: Publish to MCP Registry
52-
run: mcp-publisher publish
50+
run: ./mcp-publisher publish

.releaserc.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@
88
[
99
"@semantic-release/exec",
1010
{
11-
"prepareCmd": "node scripts/sync-manifest-version.js && pnpm run dxt:pack && pnpm run mcpb:pack"
11+
"prepareCmd": "node scripts/sync-manifest-version.js && pnpm run dxt:pack && pnpm run mcpb:pack && node scripts/update-server-json.js"
1212
}
1313
],
1414
[
1515
"@semantic-release/git",
1616
{
17-
"assets": ["CHANGELOG.md", "package.json", "manifest.json"],
17+
"assets": [
18+
"CHANGELOG.md",
19+
"package.json",
20+
"manifest.json",
21+
"server.json"
22+
],
1823
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
1924
}
2025
],
@@ -31,6 +36,11 @@
3136
"path": "pageindex-mcp.mcpb",
3237
"name": "pageindex-mcp-${nextRelease.version}.mcpb",
3338
"label": "pageindex-mcp-${nextRelease.version}.mcpb"
39+
},
40+
{
41+
"path": "server.json",
42+
"name": "server.json",
43+
"label": "server.json"
3444
}
3545
]
3646
}

scripts/update-server-json.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env node
2+
import { createHash } from 'node:crypto';
3+
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
4+
5+
function sha256OfFile(path) {
6+
const buf = readFileSync(path);
7+
return createHash('sha256').update(buf).digest('hex');
8+
}
9+
10+
try {
11+
const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
12+
13+
// Find the .mcpb file
14+
const mcpbFiles = readdirSync('.').filter((f) => f.endsWith('.mcpb'));
15+
const mcpbFile = mcpbFiles[0] || 'pageindex-mcp.mcpb';
16+
17+
// Calculate hash if file exists
18+
const hash = existsSync(mcpbFile) ? sha256OfFile(mcpbFile) : '';
19+
20+
const server = existsSync('server.json')
21+
? JSON.parse(readFileSync('server.json', 'utf8'))
22+
: {};
23+
24+
// Update version
25+
server.version = pkg.version;
26+
27+
// Update packages
28+
if (server.packages && server.packages.length > 0) {
29+
// Update npm package (first entry)
30+
if (server.packages[0].registry_type === 'npm') {
31+
server.packages[0].version = pkg.version;
32+
}
33+
34+
// Update MCPB package (second entry)
35+
if (
36+
server.packages.length > 1 &&
37+
server.packages[1].registry_type === 'mcpb'
38+
) {
39+
server.packages[1].version = pkg.version;
40+
server.packages[1].identifier = `https://github.com/VectifyAI/pageindex-mcp/releases/download/v${pkg.version}/pageindex-mcp-${pkg.version}.mcpb`;
41+
server.packages[1].file_sha256 = hash;
42+
server.packages[1].transport = {
43+
type: 'stdio',
44+
};
45+
}
46+
}
47+
48+
writeFileSync('server.json', `${JSON.stringify(server, null, 2)}\n`);
49+
console.log('server.json updated:', {
50+
version: pkg.version,
51+
npm_package: server.packages?.[0]?.identifier,
52+
mcpb_package: server.packages?.[1]?.identifier,
53+
file_sha256: hash || '(hash will be calculated after mcpb build)',
54+
});
55+
} catch (err) {
56+
console.error('Failed to update server.json:', err.message);
57+
process.exit(1);
58+
}

server.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,26 @@
33
"name": "io.github.vectifyai/pageindex-mcp",
44
"title": "PageIndex MCP",
55
"description": "MCP server for PageIndex - a reasoning-based RAG system for chatting with long PDFs. Supports local and online PDFs with unlimited conversations and free 1000 pages.",
6-
"version": "1.5.0",
7-
"homepage": "https://pageindex.ai/mcp",
6+
"status": "active",
87
"repository": {
9-
"type": "git",
10-
"url": "https://github.com/VectifyAI/pageindex-mcp"
8+
"url": "https://github.com/VectifyAI/pageindex-mcp",
9+
"source": "github"
1110
},
12-
"license": "MIT",
11+
"version": "1.5.0",
1312
"packages": [
1413
{
15-
"registryType": "npm",
14+
"registry_type": "npm",
15+
"version": "1.5.0",
1616
"identifier": "pageindex-mcp",
17+
"transport": {
18+
"type": "stdio"
19+
}
20+
},
21+
{
22+
"registry_type": "mcpb",
1723
"version": "1.5.0",
24+
"identifier": "https://github.com/VectifyAI/pageindex-mcp/releases/download/v1.5.0/pageindex-mcp-1.5.0.mcpb",
25+
"file_sha256": "",
1826
"transport": {
1927
"type": "stdio"
2028
}

0 commit comments

Comments
 (0)