@@ -5,6 +5,7 @@ Set up automated MCP server publishing using GitHub Actions.
55## What You'll Learn
66
77By the end of this tutorial, you'll have:
8+
89- A GitHub Actions workflow that automatically publishes your server
910- Understanding of GitHub OIDC authentication
1011- Knowledge of best practices for automated publishing
@@ -28,52 +29,52 @@ name: Publish to MCP Registry
2829
2930on :
3031 push :
31- tags : ['v*'] # Triggers on version tags like v1.0.0
32+ tags : ["v*"] # Triggers on version tags like v1.0.0
3233
3334jobs :
3435 publish :
3536 runs-on : ubuntu-latest
3637 permissions :
37- id-token : write # Required for OIDC authentication
38+ id-token : write # Required for OIDC authentication
3839 contents : read
39-
40+
4041 steps :
4142 - name : Checkout code
4243 uses : actions/checkout@v4
43-
44- - name : Setup Node.js # Adjust for your language
44+
45+ - name : Setup Node.js # Adjust for your language
4546 uses : actions/setup-node@v4
4647 with :
47- node-version : ' 20 '
48- registry-url : ' https://registry.npmjs.org'
49-
48+ node-version : " 20 "
49+ registry-url : " https://registry.npmjs.org"
50+
5051 - name : Install dependencies
5152 run : npm ci
52-
53+
5354 - name : Run tests
5455 run : npm test
55-
56- - name : Build package
56+
57+ - name : Build package
5758 run : npm run build
58-
59+
5960 - name : Publish to npm
6061 run : npm publish
6162 env :
6263 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
63-
64+
6465 - name : Install MCP Publisher
6566 run : |
6667 # Build publisher from source (requires Go)
6768 git clone https://github.com/modelcontextprotocol/registry publisher-repo
6869 cd publisher-repo
6970 make publisher
70- cp cmd/publisher/ bin/mcp-publisher ../mcp-publisher
71+ cp bin/mcp-publisher ../mcp-publisher
7172 cd ..
7273 chmod +x mcp-publisher
73-
74+
7475 - name : Login to MCP Registry
7576 run : ./mcp-publisher login github-oidc
76-
77+
7778 - name : Publish to MCP Registry
7879 run : ./mcp-publisher publish
7980` ` `
@@ -97,8 +98,9 @@ git push origin v1.0.0
9798` ` `
9899
99100The workflow will :
101+
1001021. Run tests
101- 2. Build your package
103+ 2. Build your package
1021043. Publish to npm
1031054. Automatically authenticate with the MCP Registry
1041065. Publish updated server.json
@@ -112,7 +114,8 @@ The workflow will:
112114 run: mcp-publisher login github-oidc
113115` ` `
114116
115- **Advantages:**
117+ **Advantages:**
118+
116119- No secrets to manage
117120- Automatically scoped to your repository
118121- Most secure option
@@ -150,40 +153,40 @@ name: Publish Python MCP Server
150153
151154on:
152155 push:
153- tags: ['v*' ]
156+ tags: ["v*" ]
154157
155158jobs:
156159 publish:
157160 runs-on: ubuntu-latest
158161 permissions:
159162 id-token: write
160163 contents: read
161-
164+
162165 steps:
163166 - uses: actions/checkout@v4
164-
167+
165168 - name: Setup Python
166169 uses: actions/setup-python@v4
167170 with:
168- python-version: ' 3.11'
169-
171+ python-version: " 3.11"
172+
170173 - name: Install Poetry
171174 run: pipx install poetry
172-
175+
173176 - name: Build package
174177 run: poetry build
175-
178+
176179 - name: Publish to PyPI
177180 run: poetry publish
178181 env:
179182 POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
180-
183+
181184 - name: Install MCP Publisher
182185 run: |
183186 git clone https://github.com/modelcontextprotocol/registry publisher-repo
184187 cd publisher-repo && make publisher && cd ..
185- cp publisher-repo/cmd/publisher/ bin/mcp-publisher mcp-publisher
186-
188+ cp publisher-repo/bin/mcp-publisher mcp-publisher
189+
187190 - name: Publish to MCP Registry
188191 run: |
189192 ./mcp-publisher login github-oidc
@@ -197,31 +200,31 @@ name: Publish Docker MCP Server
197200
198201on:
199202 push:
200- tags: ['v*' ]
203+ tags: ["v*" ]
201204
202205jobs:
203206 publish:
204207 runs-on: ubuntu-latest
205208 permissions:
206209 id-token: write
207210 contents: read
208-
211+
209212 steps:
210213 - uses: actions/checkout@v4
211-
214+
212215 - name: Setup Docker Buildx
213216 uses: docker/setup-buildx-action@v3
214-
217+
215218 - name: Login to Docker Hub
216219 uses: docker/login-action@v3
217220 with:
218221 username: ${{ secrets.DOCKER_USERNAME }}
219222 password: ${{ secrets.DOCKER_PASSWORD }}
220-
223+
221224 - name: Extract version
222225 id: version
223226 run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
224-
227+
225228 - name: Build and push
226229 uses: docker/build-push-action@v5
227230 with:
@@ -230,20 +233,19 @@ jobs:
230233 tags: yourname/your-server:${{ steps.version.outputs.version }}
231234 labels: |
232235 io.modelcontextprotocol.server.name=io.github.yourname/your-server
233-
236+
234237 - name: Install MCP Publisher
235238 run: |
236239 git clone https://github.com/modelcontextprotocol/registry publisher-repo
237240 cd publisher-repo && make publisher && cd ..
238- cp publisher-repo/cmd/publisher/ bin/mcp-publisher mcp-publisher
239-
241+ cp publisher-repo/bin/mcp-publisher mcp-publisher
242+
240243 - name: Publish to MCP Registry
241244 run: |
242245 ./mcp-publisher login github-oidc
243246 ./mcp-publisher publish
244247` ` `
245248
246-
247249# # Best Practices
248250
249251# ## 1. Version Alignment
@@ -272,7 +274,6 @@ Only publish to registry after package publishing succeeds:
272274 run: ./mcp-publisher publish
273275` ` `
274276
275-
276277# # Troubleshooting
277278
278279**"Publisher binary not found"** - Ensure you download the correct binary for your CI platform (linux/mac/windows).
@@ -286,11 +287,12 @@ Only publish to registry after package publishing succeeds:
286287# # What You've Accomplished
287288
288289You now have automated MCP server publishing that :
290+
289291- Triggers on version tags
290292- Runs tests before publishing
291293- Publishes to package registry first
292294- Automatically publishes to MCP Registry
293295- Handles authentication securely
294296- Provides failure notifications
295297
296- Your MCP server publishing is now fully automated - just tag a release and everything happens automatically!
298+ Your MCP server publishing is now fully automated - just tag a release and everything happens automatically!
0 commit comments