diff --git a/configuration/default_settings.jsonc b/configuration/default_settings.jsonc index f323533..3380537 100644 --- a/configuration/default_settings.jsonc +++ b/configuration/default_settings.jsonc @@ -1,4 +1,6 @@ { /// Your GitHub Personal Access Token "github_personal_access_token": "GITHUB_PERSONAL_ACCESS_TOKEN" + /// Your GitHub Host URL when customized (Optional) + // "github_host": "https://ghe.example.com/" } diff --git a/configuration/installation_instructions.md b/configuration/installation_instructions.md index 0364487..86df1ed 100644 --- a/configuration/installation_instructions.md +++ b/configuration/installation_instructions.md @@ -1 +1,3 @@ To use GitHub's MCP, go to your account's Developer Settings and [create a Personal Access Token](https://github.com/settings/tokens). + +You may setup GitHub host when using custom URL slugs. For more information, see [GitHub MCP with Enterprise Server](https://github.com/github/github-mcp-server#github-enterprise-server-and-enterprise-cloud-with-data-residency-ghecom). diff --git a/src/mcp_server_github.rs b/src/mcp_server_github.rs index 86dadf4..9f85482 100644 --- a/src/mcp_server_github.rs +++ b/src/mcp_server_github.rs @@ -12,6 +12,7 @@ const BINARY_NAME: &str = "github-mcp-server"; #[derive(Debug, Deserialize, JsonSchema)] struct GitHubContextServerSettings { github_personal_access_token: String, + github_host: Option, } struct GitHubModelContextExtension { @@ -113,13 +114,19 @@ impl zed::Extension for GitHubModelContextExtension { let settings: GitHubContextServerSettings = serde_json::from_value(settings).map_err(|e| e.to_string())?; + let mut env: Vec<(String, String)> = vec![( + "GITHUB_PERSONAL_ACCESS_TOKEN".into(), + settings.github_personal_access_token, + )]; + + if let Some(github_host) = settings.github_host.filter(|h| !h.trim().is_empty()) { + env.push(("GITHUB_HOST".into(), github_host)); + } + Ok(Command { command: self.context_server_binary_path(context_server_id)?, args: vec!["stdio".to_string()], - env: vec![( - "GITHUB_PERSONAL_ACCESS_TOKEN".into(), - settings.github_personal_access_token, - )], + env, }) }