Skip to content

Commit 419f171

Browse files
committed
Separate out MCP token
1 parent fc8527d commit 419f171

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,26 @@ steps:
168168
token: ${{ secrets.USER_PAT }}
169169
```
170170

171+
For enhanced security, you can use separate tokens for the AI inference endpoint
172+
and the GitHub MCP server:
173+
174+
```yaml
175+
steps:
176+
- name: AI Inference with Separate MCP Token
177+
id: inference
178+
uses: actions/[email protected]
179+
with:
180+
prompt: 'List my open pull requests and create a summary'
181+
enable-github-mcp: true
182+
token: ${{ secrets.AI_INFERENCE_TOKEN }}
183+
github-mcp-token: ${{ secrets.GITHUB_MCP_TOKEN }}
184+
```
185+
171186
When MCP is enabled, the AI model will have access to GitHub tools and can
172187
perform actions like searching issues and PRs.
173188

174-
**Note:** For now, MCP integration cannot be used with the built-in token. You
175-
must pass a GitHub PAT into `token:` instead.
189+
**Note:** You can use the built-in `GITHUB_TOKEN`, or provide a separate GitHub
190+
PAT via `github-mcp-token` for tighter security and permissions control.
176191

177192
## Inputs
178193

@@ -191,6 +206,7 @@ the action:
191206
| `endpoint` | The endpoint to use for inference. If you're running this as part of an org, you should probably use the org-specific Models endpoint | `https://models.github.ai/inference` |
192207
| `max-tokens` | The max number of tokens to generate | 200 |
193208
| `enable-github-mcp` | Enable Model Context Protocol integration with GitHub tools | `false` |
209+
| `github-mcp-token` | Token to use for GitHub MCP server (defaults to the main token if not specified). Use a separate PAT for tighter security | `""` |
194210

195211
## Outputs
196212

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ inputs:
5050
description: Enable Model Context Protocol integration with GitHub tools
5151
required: false
5252
default: 'false'
53+
github-mcp-token:
54+
description: The token to use for GitHub MCP server (defaults to GITHUB_TOKEN if not specified)
55+
required: false
56+
default: ''
5357

5458
# Define your outputs here.
5559
outputs:

dist/index.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ export async function run(): Promise<void> {
4949
throw new Error('GITHUB_TOKEN is not set')
5050
}
5151

52+
// Get GitHub MCP token (use dedicated token if provided, otherwise fall back to main token)
53+
const githubMcpToken = core.getInput('github-mcp-token') || token
54+
5255
const endpoint = core.getInput('endpoint')
5356

5457
// Build the inference request with pre-processed messages and response format
@@ -67,7 +70,7 @@ export async function run(): Promise<void> {
6770
let modelResponse: string | null = null
6871

6972
if (enableMcp) {
70-
const mcpClient = await connectToGitHubMCP(inferenceRequest.token)
73+
const mcpClient = await connectToGitHubMCP(githubMcpToken)
7174

7275
if (mcpClient) {
7376
modelResponse = await mcpInference(inferenceRequest, mcpClient)

0 commit comments

Comments
 (0)