Commit Graph

313 Commits

Author SHA1 Message Date
Sam Morrow 3dc1535b88 Accept bare method names in symbol extraction
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
Build and Test Go Project / build (macos-latest) (push) Has been cancelled
Build and Test Go Project / build (ubuntu-latest) (push) Has been cancelled
Build and Test Go Project / build (windows-latest) (push) Has been cancelled
When searching for a symbol like 'RegisterRoutes', if no exact match
is found, try suffix matching against receiver-qualified names like
'(*Handler).RegisterRoutes'. Returns the match only when unambiguous
(exactly one suffix match).

Error messages now suggest the closest match when a suffix match exists
but wasn't used (e.g., when there are multiple types with the same
method name).

Updated the symbol parameter description to document the receiver
prefix format and note that bare names work when unambiguous.
2026-02-10 11:17:02 +01:00
Sam Morrow d4a483feb4 Replace opaque tree-sitter names with actual code
Multi-var/const blocks now extract all declared names from var_spec_list
children (e.g., 'globalMap, oldRegexp' instead of '_var_declaration_19').
For >3 names, shows first two plus count.

Var/const blocks are keyed by position (like imports) so adding/removing
a variable shows as 'modified' with inline diff rather than remove+add.

When name extraction returns empty, falls back to showing the first line
of the declaration text instead of opaque '_kind_N' indices. This ensures
no tree-sitter internal names appear in output.
2026-02-10 10:59:57 +01:00
Sam Morrow ab759201c8 Fix package_clause naming and add declaration summaries for new/deleted files
Package clauses now extract the package name from the package_identifier
child node, showing 'package handler' instead of '_package_clause_0'.

New and deleted code files now show a declaration summary listing all
top-level symbols with their signatures, rather than just 'file added'
or 'file deleted'. This gives the model a table-of-contents view of
what was added/removed.
2026-02-10 00:20:16 +01:00
Sam Morrow 8473740812 Improve import naming and added declaration output
Import declarations now show package names instead of opaque
_import_declaration_N identifiers. Go imports extract short package
names (e.g., 'fmt, http, context'). For large import blocks, shows
first two and count (e.g., 'fmt, http, ... (5 packages)').

Import blocks are keyed by position rather than name, so changing the
imported packages shows as 'modified' with inline diff instead of
separate remove+add entries.

Added declarations now show their signature (first line) to give
context about what was added, rather than just the word 'added'.
2026-02-10 00:16:34 +01:00
Sam Morrow 88a6a37c51 Apply semantic diffs to get_commit, get_diff, and get_files
Integrates the semantic diff engine into existing tools that return
file patches:

- get_commit: Adds Patch field to MinimalCommitFile and applies
  semantic diff for supported formats (JSON, YAML, CSV, TOML) and
  structural diff for code files
- pull_request_read (get_diff): Splits multi-file raw diff by file
  and applies semantic diff per-file where beneficial
- pull_request_read (get_files): Applies semantic diff to each
  file's Patch field before returning

Unsupported file types keep their original unified diff patches
unchanged. Patches are reconstructed from hunks to feed the semantic
diff engine — this works well for structured data where the full
content is typically in the diff.
2026-02-10 00:09:41 +01:00
Sam Morrow d0290bf74e Include file SHA in symbol extraction text result
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
Build and Test Go Project / build (macos-latest) (push) Has been cancelled
Build and Test Go Project / build (ubuntu-latest) (push) Has been cancelled
Build and Test Go Project / build (windows-latest) (push) Has been cancelled
2026-02-10 00:04:13 +01:00
Sam Morrow fb8a684d15 Add repos toolset server instructions for multi-tool workflow
Adds InstructionsFunc to the repos toolset describing how to combine
compare_file_contents (structural diff) with get_file_contents symbol
extraction for efficient code review. Server instructions focus on
multi-tool flows only — single-tool features are already documented
in each tool's own description.
2026-02-10 00:00:22 +01:00
Sam Morrow 04e669ae1b Return plain text for symbol extraction instead of embedded resource
Symbol text is just code — a ResourceContents wrapper with URI/MIME
type adds no value. Use NewToolResultText for a simpler, more natural
response.
2026-02-09 23:56:19 +01:00
Sam Morrow db10882206 Add symbol extraction to get_file_contents tool
Adds an optional 'symbol' parameter to get_file_contents that uses
tree-sitter to extract a specific named symbol (function, class, type,
method, etc.) from a file. Instead of returning the entire file, only
the matching symbol's source code is returned.

Supports all languages from the structural diff engine: Go, Python,
JavaScript, TypeScript, Ruby, Rust, Java, C/C++. For unsupported
file types, returns an error suggesting the feature is not available.

If the symbol is not found, the error message includes a list of
available symbols in the file to help the model self-correct.

This pairs well with the structural diff tool — a model can see which
symbols changed via compare_file_contents, then fetch specific symbols
via get_file_contents to examine them in detail.
2026-02-09 23:53:40 +01:00
Sam Morrow d8ed060413 Extract names from var/const declarations in Go
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
Build and Test Go Project / build (macos-latest) (push) Has been cancelled
Build and Test Go Project / build (ubuntu-latest) (push) Has been cancelled
Build and Test Go Project / build (windows-latest) (push) Has been cancelled
var_declaration and const_declaration nodes contain spec children
(var_spec, const_spec) with name fields. The Go name extractor now
handles these the same way as type_declaration, so nested diffs show
'var_declaration storeLine' instead of '_var_declaration_25'.
2026-02-09 23:45:55 +01:00
Sam Morrow 4b0cd4c6ac Add inline diffs and recursive nesting for structural diff
Modified declarations now show what changed inside them:
- Inline line-level diffs using LCS for precise change detection
- Whitespace-normalized comparison for brace languages (Go, JS, etc.)
  so indentation-only changes collapse to '(whitespace/formatting only)'
- Exact comparison for whitespace-significant languages (Python)
- Recursive nesting into classes/modules to pinpoint which method changed
  e.g. 'class Dog: modified > method bark: modified > line change'
- Max depth of 5 prevents unbounded recursion
- Added method_definition to JS/TS/TSX declaration kinds for class methods
2026-02-09 23:43:27 +01:00
Sam Morrow d608c4b99b Add tree-sitter structural diff for code files
Extends the compare_file_contents tool with AST-based structural
diffing for code files using tree-sitter. Instead of line-based diffs,
this shows declaration-level changes (functions, classes, types) which
gives models more concise and semantically meaningful context.

Supported languages: Go, Python, JavaScript, TypeScript, Ruby, Rust,
Java, C/C++.

Requires CGO_ENABLED=1 for the tree-sitter C bindings. Windows builds
are removed from goreleaser as CGO cross-compilation is not supported
without additional toolchain setup.

For unsupported languages, falls back to unified line-based diff.
2026-02-09 23:20:55 +01:00
Sam Morrow 1777da6eba Add feature-flagged compare_file_contents tool with semantic diffs
Add a new compare_file_contents MCP tool that compares two versions of a
file across refs (branches, tags, or SHAs). For structured data formats
(JSON, YAML, CSV, TOML), it produces semantic diffs that show only
meaningful changes, ignoring formatting differences. For unsupported
formats, it falls back to unified diff.

Key features:
- Semantic diffs for JSON, YAML, CSV, TOML files
- Unified diff fallback for code and other text files
- Handles new files (base not found) and deleted files (head not found)
- 1MB max file size to prevent excessive server-side processing
- Gated behind 'compare_file_contents' feature flag

This helps AI models by:
- Reducing token usage (formatting noise eliminated)
- Providing unambiguous before/after semantics
- Enabling self-verification of edits to config/data files

Refs: #1973
2026-02-09 22:50:59 +01:00
Adam Holt aa302209b0 Add Streamable HTTP mode (#1849)
Adds new `http` command supporting Streamable HTTP support, OAuth Metadata handler and Scope filtering.

Co-authored-by: kerobbi <kerobbi@github.com>
Co-authored-by: Matt Holloway <mattdholloway@github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-06 15:33:41 +01:00
Ilya Kamens a9edf9e04c Add reply to PR comment (#1856)
* Update snapshots

There was a change on `main` before I changed anything

* feat: add add_reply_to_pull_request_comment tool

Add a new tool that allows AI agents to reply to existing pull request comments. This tool uses GitHub's CreateCommentInReplyTo REST API to create threaded conversations on pull requests.

Features:

Reply to any existing PR comment using its ID
Proper error handling for missing parameters and API failures
Comprehensive test coverage (8 test cases)
Follows project patterns and conventions
Registered in pull_requests toolset as a write operation
Parameters:

owner: Repository owner (required)
repo: Repository name (required)
pullNumber: Pull request number (required)
commentId: ID of comment to reply to (required)
body: Reply text content (required)
This tool complements the existing add_comment_to_pending_review tool by enabling responses to already-posted comments, enhancing AI-powered code review workflows.

Closes: #635

* Update README

* fix types

---------

Co-authored-by: tommaso-moro <tommaso-moro@github.com>
Co-authored-by: Tommaso Moro <37270480+tommaso-moro@users.noreply.github.com>
Co-authored-by: plaskowski <1999603+plaskowski@users.noreply.github.com>
Co-authored-by: Rob Emanuele <2320142+lossyrob@users.noreply.github.com>
2026-02-04 17:46:21 +00:00
Roberto Nacu fb53abdbe2 replace context.Background() (#1948)
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
Docker / build (push) Has been cancelled
Build and Test Go Project / build (macos-latest) (push) Has been cancelled
Build and Test Go Project / build (ubuntu-latest) (push) Has been cancelled
Build and Test Go Project / build (windows-latest) (push) Has been cancelled
GoReleaser Release / release (push) Has been cancelled
MCP Server Diff / mcp-diff (push) Has been cancelled
Publish to MCP Registry / publish (push) Has been cancelled
2026-02-03 15:42:14 +00:00
tonytrg 7af51a079a adding correct insiders-mode name 2026-01-26 16:28:36 +01:00
Matt Holloway 60a8c21b8a remove old flags 2026-01-26 16:02:20 +01:00
Matt Holloway 0a62aabc94 default to consolidated actions/projects toolsets and add hold back flag 2026-01-26 15:07:38 +01:00
Tommaso Moro 15e66b3df3 Generate server instructions in Inventory (#1869)
* carry over from https://github.com/github/github-mcp-server/pull/1863

* remove unused inv

* update toolsnap

---------

Co-authored-by: Sam Morrow <info@sam-morrow.com>
2026-01-23 09:57:47 +00:00
Sam Morrow 5e5ff27486 Address PR review feedback
- Extract dual-fetch logic into listProjectsFromBothOwnerTypes helper
- Rename addProjectItemWithResolution to addProjectItem (old function removed)
- Add GraphQL test coverage for add_project_item using githubv4mock
- Tests cover both org/issue and user/pull_request success paths
2026-01-22 23:27:21 +01:00
copilot-swe-agent[bot] eaaf1ea833 Update consolidated projects tools: make owner_type optional and fix add_project_item
Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>

Fix tests and update toolsnaps for consolidated projects tools

Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
2026-01-22 23:27:21 +01:00
Sam Morrow a663a6b1f8 feat: add progress notifications during PR polling in assign_copilot_to_issue
Add MCP progress notifications during the PR polling loop to provide
real-time status updates while waiting for Copilot to create a PR.

Changes:
- Use the request parameter to access the ServerSession for notifications
- Send an initial progress notification when polling starts
- Send progress updates on each polling attempt with attempt count
- Only send notifications when progressToken is provided by the client

This aligns with the behavior in create_pull_request_with_copilot tool
and improves the user experience during the waiting period.
2026-01-16 11:37:26 +01:00
Sam Morrow f1d33d51f6 refactor: use GraphQLFeaturesTransport internally
Replace inline GraphQL-Features header logic in bearerAuthTransport with
the exported GraphQLFeaturesTransport. This removes code duplication and
ensures the transport is actually used, not just exported.
2026-01-16 11:37:26 +01:00
Sam Morrow d3ff0a2d07 fix: address review feedback
- Document GraphQLFeaturesTransport is for library consumers
- Convert githubv4.Int/String to native Go types in result map
- Remove misleading log comment since tool handlers lack logger access
2026-01-16 11:37:26 +01:00
Sam Morrow 92d8d51f08 fix: remove tool name reference from pending note message 2026-01-16 11:37:26 +01:00
Sam Morrow bece2b54cc fix: filter PRs by timestamp to avoid returning stale results
When polling for a linked PR after assigning Copilot to an issue,
we now capture the assignment time before the mutation and filter
to only return PRs created after that time. This prevents the tool
from incorrectly returning old PRs from previous Copilot assignments.
2026-01-16 11:37:26 +01:00
Sam Morrow 09adfc71ba feat: poll for linked PR after assigning Copilot to issue
Enhances the assign_copilot_to_issue tool to automatically poll for
the PR created by the Copilot coding agent after assignment.

Changes:
- Add findLinkedCopilotPR() to query issue timeline for CrossReferencedEvent
  items from PRs authored by copilot-swe-agent
- Add polling loop (9 attempts, 1s delay) matching remote server latency
- Return structured JSON with PR details when found, or helpful note otherwise
- Add PollConfig for configurable polling (used in tests to disable)
- Add GraphQLFeaturesTransport for feature flag header support

The returned response now includes:
- issue_number, issue_url, owner, repo
- pull_request object (if found during polling)
- Note with instructions to use get_copilot_job_status if PR not yet created
2026-01-16 11:37:26 +01:00
Tony Truong 3af1129c6b adding feature flag on dependency level (#1801)
* wip injecting ff function into tool as dep

* remove debug

* fix linter

* add better test

* adding compile time check

* move experimental to seperate config/ff value

* adding test var

* fixing test

* adding flag and possibility to call feature checker

* fixing name
2026-01-16 11:22:39 +01:00
copilot-swe-agent[bot] ccf519177e Fix dismiss_notification to accept HTTP 204 No Content response
- Add http.StatusNoContent (204) to the list of accepted success status codes
- Add test case for 204 response when marking notification as done
- Retain existing test for 200 response for backwards compatibility

Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
2026-01-16 11:16:11 +01:00
copilot-swe-agent[bot] d88eb83a4f Add custom_instructions parameter to assign_copilot_to_issue tool
- Added optional custom_instructions parameter to tool schema
- Updated implementation to pass custom instructions to agent assignment
- Added test case to verify custom_instructions works correctly
- Updated toolsnaps and documentation

The custom_instructions parameter allows users to provide additional
context, constraints, or guidance to the Copilot agent beyond what's
in the issue body, addressing the issue where additional context
would otherwise be lost.

Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
2026-01-15 18:09:34 +01:00
Tommaso Moro 19beb33c3f Bug fix: invalid tool should error out (#1776)
* get it working

* clean up approach by moving cleantools inside builder, this simplifies remote server too

* add tests for trimming and deduplication

* error out in the builder if there are unrecognized tools

---------

Co-authored-by: Sam Morrow <info@sam-morrow.com>
2026-01-15 17:37:06 +01:00
copilot-swe-agent[bot] 0bf791a4ce Regenerate toolsnaps with deterministic sorting
Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
2026-01-15 17:33:22 +01:00
copilot-swe-agent[bot] 87a1110c15 Implement recursive JSON key sorting for toolsnaps
Sort all JSON object keys alphabetically at every level in toolsnaps by
unmarshaling and remarshaling. This leverages Go's built-in behavior where
json.Marshal automatically sorts map keys alphabetically, ensuring
consistent field ordering and eliminating noop churn in diffs.

Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
2026-01-15 16:15:39 +01:00
copilot-swe-agent[bot] d18f26e559 Add GraphQL-Features header support for agent assignment API
- Add context-based GraphQL feature flag support
- Modify bearerAuthTransport to read features from context and add GraphQL-Features header
- Use issues_copilot_assignment_api_support feature flag for updateIssue mutation
- Export GetGraphQLFeatures function for use in HTTP transport layer

This allows the assign_copilot_to_issue tool to work with the non-GA agent assignment API
by sending the required GraphQL-Features header.

Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
2026-01-12 15:45:58 +01:00
copilot-swe-agent[bot] 88d117bd82 Add base_ref support to assign_copilot_to_issue tool
- Add optional base_ref parameter to tool schema
- Change from replaceActorsForAssignable to updateIssue mutation with agentAssignment
- Add AgentAssignmentInput and UpdateIssueInput structs for new GraphQL mutation
- Update all tests to use new mutation structure
- Add test case for base_ref functionality
- Update toolsnaps and documentation

Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
2026-01-12 15:45:58 +01:00
Sam Morrow 676956faf3 Fix resource handler to use deps from context
The RepositoryResourceContentsHandler was using closure-captured deps
instead of retrieving them from context at call time. This causes issues
on the remote server which injects per-request deps via context.

Changed to use MustDepsFromContext(ctx) pattern consistent with tool
handlers in NewTool and NewToolFromHandler.
2026-01-12 14:05:19 +01:00
Sam Morrow cc9e8645c1 Fix nil pointer dereference in completion handler
The CompleteParams.Context field is optional (marked omitempty) and can be
nil when clients don't send it. The code was accessing Context.Arguments
directly without checking if Context was nil first, causing a panic.

This fix adds a nil check for Context before accessing Arguments.
2026-01-07 15:44:58 +00:00
Matt Holloway 71862a93e4 update tests to use new mock pattern 2026-01-06 17:38:12 +00:00
Matt Holloway a57b4726e5 add http resp code checking for getProjectItem 2026-01-06 17:38:12 +00:00
Matt Holloway be5a449e48 fix project tools to add scope to newtool init 2026-01-06 17:38:12 +00:00
Matt Holloway 099f995615 revert "hold-bac feature flag" 2026-01-06 17:38:12 +00:00
Matt Holloway 304f07401e hold-bac feature flag 2026-01-06 17:38:12 +00:00
Matt Holloway 3cd0be2af2 update tool aliases 2026-01-06 17:38:12 +00:00
Matt Holloway 66a01645f8 initial projects consolidation 2026-01-06 17:38:12 +00:00
Copilot 80b0306557 Replace go-github-mock with stretchr/testify for actions/issues/projects tests (#1737)
* Initial plan

* migrate tests from go-github-mock to internal testify-based mock

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* address feedback in testmock helper

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* tweak testmock path matching edge case

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* refine testmock options and path matching

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* simplify matchPath and document delete endpoint

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* Replace go-github-mock usage in tests with shared HTTP mock helper

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* Replace go-github-mock usage in tests with shared HTTP mock helper

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* fix tests and lint after mock cleanup

Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>

* Remove import completely

* Partial removal in repositories_test.go

* Final removal

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: JoannaaKL <67866556+JoannaaKL@users.noreply.github.com>
Co-authored-by: JoannaaKL <joannaakl@github.com>
2026-01-06 10:45:29 +01:00
Sam Morrow c428f72863 Don't filter read-only repo tools (work on public repos without scope) 2026-01-05 16:05:24 +00:00
Sam Morrow 46b8cb63ac Add PAT scope filtering for stdio server
Add the ability to filter tools based on token scopes for PAT users.
This uses an HTTP HEAD request to GitHub's API to discover token scopes.

New components:
- pkg/scopes/filter.go: HasRequiredScopes checks if scopes satisfy tool requirements
- pkg/scopes/fetcher.go: FetchTokenScopes gets scopes via HTTP HEAD to GitHub API
- pkg/github/scope_filter.go: CreateScopeFilter creates inventory.ToolFilter

Integration:
- Add --filter-by-scope flag to stdio command (disabled by default)
- When enabled, fetches token scopes on startup
- Tools requiring unavailable scopes are hidden from tool list
- Gracefully continues without filtering if scope fetch fails (logs warning)

This allows the OSS server to have similar scope-based tool visibility
as the remote server, and the filter logic can be reused by remote server.
2026-01-05 16:05:24 +00:00
Sam Morrow cec5a1ae0f Fix conflict and regenerate docs after rebase 2026-01-05 15:54:17 +00:00
Sam Morrow df9fc6a3b3 Use repo scope for star/unstar tools instead of public_repo
public_repo is implicit - the GitHub API handles the distinction between
public and private repos. Using repo as the required scope is more
consistent with our enforcement model:
- PATs: tools visible if token has repo scope
- OAuth: scope challenge requests repo scope
2026-01-05 15:54:17 +00:00