build index.js

This commit is contained in:
Maarten van Diemen
2025-11-02 23:37:23 +01:00
parent 932a853db4
commit 4b4b2e8afe
3 changed files with 31 additions and 22 deletions
+14 -15
View File
@@ -210,7 +210,6 @@ steps:
**Available toolsets:** **Available toolsets:**
See: https://github.com/github/github-mcp-server/blob/main/README.md#tool-configuration See: https://github.com/github/github-mcp-server/blob/main/README.md#tool-configuration
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.
@@ -219,20 +218,20 @@ perform actions like searching issues and PRs.
Various inputs are defined in [`action.yml`](action.yml) to let you configure Various inputs are defined in [`action.yml`](action.yml) to let you configure
the action: the action:
| Name | Description | Default | | Name | Description | Default |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| `token` | Token to use for inference. Typically the GITHUB_TOKEN secret | `github.token` | | `token` | Token to use for inference. Typically the GITHUB_TOKEN secret | `github.token` |
| `prompt` | The prompt to send to the model | N/A | | `prompt` | The prompt to send to the model | N/A |
| `prompt-file` | Path to a file containing the prompt (supports .txt and .prompt.yml formats). If both `prompt` and `prompt-file` are provided, `prompt-file` takes precedence | `""` | | `prompt-file` | Path to a file containing the prompt (supports .txt and .prompt.yml formats). If both `prompt` and `prompt-file` are provided, `prompt-file` takes precedence | `""` |
| `input` | Template variables in YAML format for .prompt.yml files (e.g., `var1: value1` on separate lines) | `""` | | `input` | Template variables in YAML format for .prompt.yml files (e.g., `var1: value1` on separate lines) | `""` |
| `file_input` | Template variables in YAML where values are file paths. The file contents are read and used for templating | `""` | | `file_input` | Template variables in YAML where values are file paths. The file contents are read and used for templating | `""` |
| `system-prompt` | The system prompt to send to the model | `"You are a helpful assistant"` | | `system-prompt` | The system prompt to send to the model | `"You are a helpful assistant"` |
| `system-prompt-file` | Path to a file containing the system prompt. If both `system-prompt` and `system-prompt-file` are provided, `system-prompt-file` takes precedence | `""` | | `system-prompt-file` | Path to a file containing the system prompt. If both `system-prompt` and `system-prompt-file` are provided, `system-prompt-file` takes precedence | `""` |
| `model` | The model to use for inference. Must be available in the [GitHub Models](https://github.com/marketplace?type=models) catalog | `openai/gpt-4o` | | `model` | The model to use for inference. Must be available in the [GitHub Models](https://github.com/marketplace?type=models) catalog | `openai/gpt-4o` |
| `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). This must be a PAT for MCP to work | `""` | | `github-mcp-token` | Token to use for GitHub MCP server (defaults to the main token if not specified). This must be a PAT for MCP to work | `""` |
| `github-mcp-toolsets` | Comma-separated list of toolsets to enable for GitHub MCP (e.g., `repos,issues,pull_requests,actions`). Use `all` for all toolsets or `default` for the default set | `""` | | `github-mcp-toolsets` | Comma-separated list of toolsets to enable for GitHub MCP (e.g., `repos,issues,pull_requests,actions`). Use `all` for all toolsets or `default` for the default set | `""` |
## Outputs ## Outputs
Generated Vendored
+16 -6
View File
@@ -42717,15 +42717,24 @@ class StreamableHTTPClientTransport {
/** /**
* Connect to the GitHub MCP server and retrieve available tools * Connect to the GitHub MCP server and retrieve available tools
*/ */
async function connectToGitHubMCP(token) { async function connectToGitHubMCP(token, toolsets) {
const githubMcpUrl = 'https://api.githubcopilot.com/mcp/'; const githubMcpUrl = 'https://api.githubcopilot.com/mcp/';
coreExports.info('Connecting to GitHub MCP server...'); coreExports.info('Connecting to GitHub MCP server...');
const headers = {
Authorization: `Bearer ${token}`,
'X-MCP-Readonly': 'true',
};
// Add toolsets header if specified
if (toolsets && toolsets.trim() !== '') {
headers['X-MCP-Toolsets'] = toolsets;
coreExports.info(`Using GitHub MCP toolsets: ${toolsets}`);
}
else {
coreExports.info('Using default GitHub MCP toolsets');
}
const transport = new StreamableHTTPClientTransport(new URL(githubMcpUrl), { const transport = new StreamableHTTPClientTransport(new URL(githubMcpUrl), {
requestInit: { requestInit: {
headers: { headers,
Authorization: `Bearer ${token}`,
'X-MCP-Readonly': 'true',
},
}, },
}); });
const client = new Client({ const client = new Client({
@@ -52642,13 +52651,14 @@ async function run() {
} }
// Get GitHub MCP token (use dedicated token if provided, otherwise fall back to main token) // Get GitHub MCP token (use dedicated token if provided, otherwise fall back to main token)
const githubMcpToken = coreExports.getInput('github-mcp-token') || token; const githubMcpToken = coreExports.getInput('github-mcp-token') || token;
const githubMcpToolsets = coreExports.getInput('github-mcp-toolsets');
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(githubMcpToken); const mcpClient = await connectToGitHubMCP(githubMcpToken, githubMcpToolsets);
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