Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions configuration/default_settings.jsonc
Original file line number Diff line number Diff line change
@@ -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/"
}
2 changes: 2 additions & 0 deletions configuration/installation_instructions.md
Original file line number Diff line number Diff line change
@@ -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).
15 changes: 11 additions & 4 deletions src/mcp_server_github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
}

struct GitHubModelContextExtension {
Expand Down Expand Up @@ -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,
})
}

Expand Down