Separate out MCP token

This commit is contained in:
Sean Goedecke
2025-08-04 03:06:53 +00:00
parent fc8527d1d9
commit 419f171f16
5 changed files with 30 additions and 5 deletions
+18 -2
View File
@@ -168,11 +168,26 @@ steps:
token: ${{ secrets.USER_PAT }} token: ${{ secrets.USER_PAT }}
``` ```
For enhanced security, you can use separate tokens for the AI inference endpoint
and the GitHub MCP server:
```yaml
steps:
- name: AI Inference with Separate MCP Token
id: inference
uses: actions/[email protected]
with:
prompt: 'List my open pull requests and create a summary'
enable-github-mcp: true
token: ${{ secrets.AI_INFERENCE_TOKEN }}
github-mcp-token: ${{ secrets.GITHUB_MCP_TOKEN }}
```
When MCP is enabled, the AI model will have access to GitHub tools and can When MCP is enabled, the AI model will have access to GitHub tools and can
perform actions like searching issues and PRs. perform actions like searching issues and PRs.
**Note:** For now, MCP integration cannot be used with the built-in token. You **Note:** You can use the built-in `GITHUB_TOKEN`, or provide a separate GitHub
must pass a GitHub PAT into `token:` instead. PAT via `github-mcp-token` for tighter security and permissions control.
## Inputs ## Inputs
@@ -191,6 +206,7 @@ the action:
| `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` | | `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` |
| `max-tokens` | The max number of tokens to generate | 200 | | `max-tokens` | The max number of tokens to generate | 200 |
| `enable-github-mcp` | Enable Model Context Protocol integration with GitHub tools | `false` | | `enable-github-mcp` | Enable Model Context Protocol integration with GitHub tools | `false` |
| `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 | `""` |
## Outputs ## Outputs
+4
View File
@@ -50,6 +50,10 @@ inputs:
description: Enable Model Context Protocol integration with GitHub tools description: Enable Model Context Protocol integration with GitHub tools
required: false required: false
default: 'false' default: 'false'
github-mcp-token:
description: The token to use for GitHub MCP server (defaults to GITHUB_TOKEN if not specified)
required: false
default: ''
# Define your outputs here. # Define your outputs here.
outputs: outputs:
Generated Vendored
+3 -1
View File
@@ -52130,13 +52130,15 @@ async function run() {
if (token === undefined) { if (token === undefined) {
throw new Error('GITHUB_TOKEN is not set'); throw new Error('GITHUB_TOKEN is not set');
} }
// Get GitHub MCP token (use dedicated token if provided, otherwise fall back to main token)
const githubMcpToken = coreExports.getInput('github-mcp-token') || token;
const endpoint = coreExports.getInput('endpoint'); const endpoint = coreExports.getInput('endpoint');
// Build the inference request with pre-processed messages and response format // Build the inference request with pre-processed messages and response format
const inferenceRequest = buildInferenceRequest(promptConfig, systemPrompt, prompt, modelName, maxTokens, endpoint, token); const inferenceRequest = buildInferenceRequest(promptConfig, systemPrompt, prompt, modelName, maxTokens, endpoint, token);
const enableMcp = coreExports.getBooleanInput('enable-github-mcp') || false; const enableMcp = coreExports.getBooleanInput('enable-github-mcp') || false;
let modelResponse = null; let modelResponse = null;
if (enableMcp) { if (enableMcp) {
const mcpClient = await connectToGitHubMCP(inferenceRequest.token); const mcpClient = await connectToGitHubMCP(githubMcpToken);
if (mcpClient) { if (mcpClient) {
modelResponse = await mcpInference(inferenceRequest, mcpClient); modelResponse = await mcpInference(inferenceRequest, mcpClient);
} }
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+4 -1
View File
@@ -49,6 +49,9 @@ export async function run(): Promise<void> {
throw new Error('GITHUB_TOKEN is not set') throw new Error('GITHUB_TOKEN is not set')
} }
// Get GitHub MCP token (use dedicated token if provided, otherwise fall back to main token)
const githubMcpToken = core.getInput('github-mcp-token') || token
const endpoint = core.getInput('endpoint') const endpoint = core.getInput('endpoint')
// Build the inference request with pre-processed messages and response format // Build the inference request with pre-processed messages and response format
@@ -67,7 +70,7 @@ export async function run(): Promise<void> {
let modelResponse: string | null = null let modelResponse: string | null = null
if (enableMcp) { if (enableMcp) {
const mcpClient = await connectToGitHubMCP(inferenceRequest.token) const mcpClient = await connectToGitHubMCP(githubMcpToken)
if (mcpClient) { if (mcpClient) {
modelResponse = await mcpInference(inferenceRequest, mcpClient) modelResponse = await mcpInference(inferenceRequest, mcpClient)