Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(examples): Add Gitpod MCP server example #60

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint fix
  • Loading branch information
Siddhant-K-code committed Feb 19, 2025
commit 743fed818090b2542e96bb668b140f1f163e8c42
17 changes: 7 additions & 10 deletions examples/mcp-server/server.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import os
import sys
import asyncio
import json
import logging
import threading
from typing import Optional
import os

from gitpod import Gitpod, AsyncGitpod
from gitpod import AsyncGitpod
import gitpod.lib as util
from gitpod.types.environment_spec_param import EnvironmentSpecParam
from gitpod.types.environment_initializer_param import Spec
@@ -52,22 +50,21 @@ def _setup_client(self):

if not self.gitpod_api_key:
# Try to load from claude_desktop_config.json as fallback
config_path = os.path.expanduser("~/Library/Application Support/Claude/claude_desktop_config.json")
config_path = os.path.expanduser("~/Library/Application\ Support/Claude/claude_desktop_config.json")
try:
import json
with open(config_path) as f:
config = json.load(f)
self.gitpod_api_key = config["mcpServers"]["gitpod-mcp"]["env"]["GITPOD_API_KEY"]
logger.info("Successfully loaded API key from claude_desktop_config.json")
except FileNotFoundError:
logger.error(f"Config file not found at {config_path}")
raise ValueError("GITPOD_API_KEY not found in environment or config file")
raise ValueError("GITPOD_API_KEY not found in environment or config file") from None
except KeyError as e:
logger.error(f"Missing key in config file: {e}")
raise ValueError(f"Invalid config structure: {e}")
raise ValueError(f"Invalid config structure: {e}") from e
except Exception as e:
logger.error(f"Unexpected error loading config: {str(e)}", exc_info=True)
raise ValueError("Failed to load GITPOD_API_KEY from config")
raise ValueError("Failed to load GITPOD_API_KEY from config") from e

# Initialize Gitpod client
try:
Loading
Oops, something went wrong.
Loading
Oops, something went wrong.