From fb657d1267be9ec5576df7ceffa23df5c4532269 Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Sun, 18 May 2025 08:06:40 -0400 Subject: [PATCH] feat: enhance GitHub PAT retrieval and add MCP server configuration --- .devcontainer/library-scripts/load-env.sh | 12 +++++++++++- .vscode/settings.json | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.devcontainer/library-scripts/load-env.sh b/.devcontainer/library-scripts/load-env.sh index b145bed..82da72f 100755 --- a/.devcontainer/library-scripts/load-env.sh +++ b/.devcontainer/library-scripts/load-env.sh @@ -12,12 +12,22 @@ set -o pipefail # Try to get PAT from environment first pat="${GITHUB_PERSONAL_ACCESS_TOKEN:-}" -# If not in environment, try to get from GitHub CLI +# If not in environment, try to get from .env file +if [[ -z "${pat}" ]] || [[ "${#pat}" -lt 30 ]]; then + if [[ -f "${containerWorkspaceFolder}/.devcontainer/.env" ]]; then + source "${containerWorkspaceFolder}/.devcontainer/.env" + pat="${GITHUB_PERSONAL_ACCESS_TOKEN:-}" + fi +fi + +# If still not set, try to get from GitHub CLI if [[ -z "${pat}" ]] || [[ "${#pat}" -lt 30 ]]; then if command -v gh &> /dev/null; then if gh auth status &> /dev/null; then pat=$(gh auth token) if [[ -n "${pat}" ]] && [[ "${#pat}" -gt 30 ]]; then + # Export the token to environment + export GITHUB_PERSONAL_ACCESS_TOKEN="${pat}" # Save the token to .env file if it's valid ENV_FILE="/workspaces/finance/.devcontainer/.env" echo "# GitHub Finance Devcontainer Configuration" > "${ENV_FILE}" diff --git a/.vscode/settings.json b/.vscode/settings.json index 0d5a97c..012df2d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,5 +18,23 @@ "port": "443", "baseUrl": "https://finance-app-production.example.com/api" } + }, + "mcp": { + "servers": { + "github": { + "command": "docker", + "args": [ + "run", + "-i", + "--rm", + "-e", + "GITHUB_PERSONAL_ACCESS_TOKEN=${env:GITHUB_PERSONAL_ACCESS_TOKEN}", + "ghcr.io/github/github-mcp-server" + ], + "env": { + "GITHUB_PERSONAL_ACCESS_TOKEN": "${env:GITHUB_PERSONAL_ACCESS_TOKEN}" + } + } + } } }