Skip to content

Commit 862cb8e

Browse files
xperiandriclaude
andcommitted
Improved Claude Code integration
* Authenticate the GitHub MCP server in Claude Code through a `headersHelper` that reuses the GitHub token stored by Git Credential Manager. The server does not support dynamic client registration, so the OAuth flow of Claude Code fails. The helper prints `{}` when there is no credential. * Sort MCP servers alphabetically and replace the server table in the instructions with hints on when to prefer a server. * Add `AGENTS.md` pointing at the shared instructions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 401874b commit 862cb8e

4 files changed

Lines changed: 45 additions & 27 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Emits GitHub MCP request headers for Claude Code's `headersHelper`.
2+
# Reuses the GitHub OAuth token stored by Git Credential Manager, so no PAT is needed.
3+
# Prints `{}` when no credential is available, so the server stays unauthenticated instead of failing.
4+
5+
$ErrorActionPreference = 'Stop'
6+
$env:GCM_INTERACTIVE = 'never'
7+
$env:GIT_TERMINAL_PROMPT = '0'
8+
9+
$token = $null
10+
try {
11+
$credential = "protocol=https`nhost=github.com`n`n" | git credential fill 2>$null
12+
$token = ($credential | Where-Object { $_ -like 'password=*' }) -replace '^password=', ''
13+
}
14+
catch {
15+
}
16+
17+
if ($token) {
18+
@{ Authorization = "Bearer $token" } | ConvertTo-Json -Compress
19+
}
20+
else {
21+
'{}'
22+
}

‎.github/copilot-instructions.md‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,12 @@ Use GitHub MCP tools for code search in these repositories when needed.
6363

6464
## MCP Servers
6565

66-
MCP server configuration lives in #file:'.mcp.json':
66+
Agents discover servers from #file:'.mcp.json'; these are only hints on when to prefer one.
6767

68-
* `servers` – read by VS Code / GitHub Copilot.
69-
* `mcpServers` – read by Claude Code. Mirrors the same servers; keep both sections in sync when adding or changing a server.
70-
71-
Local tool packages are pinned in #file:'.config/dotnet-tools.json' – run `dotnet tool restore` before first use.
72-
73-
| Server | Tool package | Command | Notes |
74-
|---|---|---|---|
75-
| `F#` | `fslangmcp` | `dotnet tool run fslangmcp` | Semantic F# MCP backed by the compiler and FSAC. Use it for cross-project symbol search, project/file outlines, diagnostics, rename previews, dead-code checks, and other F#-aware analysis that plain text search misses. See <https://github.com/Neftedollar/FsLangMCP>. |
76-
| `GitHub` | – | HTTP | Code search in dependency repositories. |
77-
| `Microsoft Docs` | – | HTTP | Official Microsoft and .NET documentation. |
78-
79-
For F# work, prefer FsLangMCP over `rg`/plain text search whenever the task depends on symbol meaning, compile context, cross-project usage, diagnostics, or safe refactoring preview.
68+
* For F# work, prefer the `F#` server ([FsLangMCP](https://github.com/Neftedollar/FsLangMCP)) over `rg`/plain text search whenever the task depends on symbol meaning, compile context, cross-project usage, diagnostics, or safe refactoring preview. Its tool package is pinned in #file:'.config/dotnet-tools.json' – run `dotnet tool restore` before first use.
69+
* Use the `GitHub` server for code search in dependency repositories. In Claude Code it authenticates through `.claude/scripts/github-mcp-headers.ps1`, which reuses the GitHub token stored by Git Credential Manager, because the server does not support the OAuth dynamic client registration Claude Code needs.
70+
* Use the `Microsoft Docs` server for official Microsoft and .NET documentation.
71+
* When adding or changing a server, keep `servers` (VS Code / GitHub Copilot) and `mcpServers` (Claude Code) in sync and sorted alphabetically by key.
8072

8173
## F# Coding Guidelines
8274

‎.mcp.json‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
{
22
"servers": {
3-
"Microsoft Docs": {
4-
"type": "http",
5-
"url": "https://learn.microsoft.com/api/mcp"
6-
},
7-
"GitHub": {
8-
"type": "http",
9-
"url": "https://api.githubcopilot.com/mcp/"
10-
},
113
"F#": {
124
"type": "stdio",
135
"command": "dotnet",
@@ -16,17 +8,17 @@
168
"run",
179
"fslangmcp"
1810
]
19-
}
20-
},
21-
"mcpServers": {
22-
"Microsoft Docs": {
23-
"type": "http",
24-
"url": "https://learn.microsoft.com/api/mcp"
2511
},
2612
"GitHub": {
2713
"type": "http",
2814
"url": "https://api.githubcopilot.com/mcp/"
2915
},
16+
"Microsoft Docs": {
17+
"type": "http",
18+
"url": "https://learn.microsoft.com/api/mcp"
19+
}
20+
},
21+
"mcpServers": {
3022
"F#": {
3123
"type": "stdio",
3224
"command": "dotnet",
@@ -35,6 +27,15 @@
3527
"run",
3628
"fslangmcp"
3729
]
30+
},
31+
"GitHub": {
32+
"type": "http",
33+
"url": "https://api.githubcopilot.com/mcp/",
34+
"headersHelper": "pwsh -NoProfile -File .claude/scripts/github-mcp-headers.ps1"
35+
},
36+
"Microsoft Docs": {
37+
"type": "http",
38+
"url": "https://learn.microsoft.com/api/mcp"
3839
}
3940
}
4041
}

‎AGENTS.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Agent Instructions
2+
3+
Before starting any task, read and follow [.github/copilot-instructions.md](.github/copilot-instructions.md). It holds the full project context and coding standards.

0 commit comments

Comments
 (0)