Skip to content

Commit 4b591cc

Browse files
authored
Merge pull request #83 from actions/sgoedecke/separate-mcp
Separate out MCP token
2 parents fc8527d + ea24ec2 commit 4b591cc

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,24 @@ steps:
168168
token: ${{ secrets.USER_PAT }}
169169
```
170170

171+
If you want, 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.GITHUB_TOKEN }}
183+
github-mcp-token: ${{ secrets.USER_PAT }}
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.
176-
177189
## Inputs
178190

179191
Various inputs are defined in [`action.yml`](action.yml) to let you configure
@@ -191,6 +203,7 @@ the action:
191203
| `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` |
192204
| `max-tokens` | The max number of tokens to generate | 200 |
193205
| `enable-github-mcp` | Enable Model Context Protocol integration with GitHub tools | `false` |
206+
| `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 | `""` |
194207

195208
## Outputs
196209

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)