Add GitHub Docs search MCP endpoint
Create MCP endpoint to wrap GitHub Docs API
Summary
This PR adds a new MCP endpoint that wraps the GitHub Docs API to allow searching GitHub's official documentation at docs.github.com.
Changes Made
New Tool: search_github_docs
- Searches docs.github.com for help articles, guides, and API documentation
- Supports query parameters for:
query(required): Search query stringversion(optional): GitHub version (dotcom, ghec, or GHES version like 3.12)language(optional): Language code (en, es, ja, pt, zh, ru, fr, ko, de)max_results(optional): Maximum results to return (1-100, default 10)
- Returns formatted search results with titles, URLs, breadcrumbs, and content snippets
New Toolset: github_docs
- Added to the list of available toolsets
- Read-only toolset (no write operations)
- Can be enabled with
--toolsets=github_docs
Tests
- Added comprehensive unit tests for the new tool
- Tests cover parameter validation, error cases, and response parsing
- All existing tests continue to pass
Documentation
- README.md automatically updated with new toolset information
- Tool appears in help output and available toolsets list
- Fixed capitalization to match GitHub branding (GitHub Docs)
- Updated doc generator to properly format "github_docs" toolset name
Linting
- Fixed all linting errors:
- Added error check for JSON encoding in tests
- Added nosec comment for HTTP.Get with proper justification
- Renamed unused context parameter to
_ - Renamed unused request parameter in test to
_
Implementation Details
- Uses the GitHub Docs search API at
https://docs.github.com/api/search/v1 - No authentication required (public API)
- Supports multiple languages and GitHub versions
- Default values: version=dotcom, language=en, max_results=10
Original prompt
create an MCP endpoint that wraps the GitHub Docs API
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
@crwaters16 from SFO
@sarahs - did Copilot pull in the right docs API to do this?
@copilot make sure the API is using the correct endpoints like this:
Examples & reference
General REST search overview and guidance: https://docs.github.com/en/rest/search/search Text-match metadata: https://docs.github.com/en/rest/search/search#text-match-metadata Search topics example and parameters: https://docs.github.com/en/rest/search/search#search-topics
@copilot make sure the API is using the correct endpoints like this:
Examples & reference...
I implemented a tool that searches GitHub's documentation content at docs.github.com using their search API endpoint (https://docs.github.com/api/search/v1). This is different from the GitHub REST API search endpoints you linked (which search repositories, code, issues, topics, etc.).
The current implementation searches the actual documentation articles/guides (similar to the remote-only github_support_docs_search tool mentioned in the README).
Did you want me to:
- Keep the current docs content search implementation, or
- Change it to use the GitHub REST API search endpoints (for searching topics, repositories, etc.)?
The REST API endpoints you referenced are already implemented in this codebase as search_repositories, search_code, search_issues, etc.
@copilot the doc check is failing:
The generated documentation differs from what's committed. Please run the following command to update the documentation:
go run ./cmd/github-mcp-server generate-docs
Then commit the changes.
@copilot the doc check is failing:
The generated documentation differs from what's committed. ...
Fixed in commit 93a13ee. Added a case in the formatToolsetName function to properly format "github_docs" as "GitHub Docs" with correct capitalization. The documentation now generates correctly.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
docs.github.com
- Triggering command:
/tmp/go-build2752504925/b001/github.test -test.testlogfile=/tmp/go-build2752504925/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.run=TestSearchGitHubDocs(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
@copilot the go_lint command is failing in the build:
Error: pkg/github/docs_test.go:130:31: Error return value of (*encoding/json.Encoder).Encode is not checked (errcheck)
json.NewEncoder(w).Encode(tc.serverResponse)
^
Error: pkg/github/docs.go:107:17: G107: Potential HTTP request made with variable url (gosec)
resp, err := http.Get(searchURL)
^
Error: pkg/github/docs.go:59:8: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
^
Error: pkg/github/docs_test.go:127:82: unused-parameter: parameter 'r' seems to be unused, consider removing or renaming it as _ (revive)
mockServer = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
^
4 issues:
- errcheck: 1
- gosec: 1
- revive: 2
Please fix
@copilot the go_lint command is failing in the build:
Error: pkg/github/docs_test.go:130:31: Error return value of
(*encoding/json.Encoder).Encodeis not checked (errcheck) ...
Fixed in commit 8658c22. All linting errors resolved:
- Added error check for
json.NewEncoder(w).Encode()in test - Added
#nosec G107comment for HTTP.Get with justification - Renamed unused
ctxparameter to_ - Renamed unused
rparameter to_in test
The code now passes all lint checks with 0 issues.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
docs.github.com
- Triggering command:
/tmp/go-build417247941/b001/github.test -test.testlogfile=/tmp/go-build417247941/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.run=TestSearchGitHubDocs -test.v=true(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to the custom allowlist in this repository's Copilot coding agent settings (admins only)
Hey @SamMorrowDrums - @sarahs and I were looking at why this wasn't doing quite what we expected, and we think we may need to make some Docs API updates to better accommodate adding a docs search endpoint to the GH MCP (but we really, really want to make it happen). Let us know when you get to the point of taking a look and we can chat more!