Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add toolsnaps for every tool #543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2025
Merged

Add toolsnaps for every tool #543

merged 3 commits into from
Jun 18, 2025

Conversation

williammartin
Copy link
Collaborator

@williammartin williammartin commented Jun 18, 2025

Description

Some time ago I introduced the idea of toolsnaps to highlight unintended changes to our tool schemas. I also imagined that it might have the benefit of quickly validating conformance if/when the project swaps to the official Go supported SDK. This PR backfills the toolsnaps to all tools.

Here's a reminder of what the error messages look like:

ok      github.com/github/github-mcp-server/internal/toolsnaps  (cached)
--- FAIL: Test_GetIssue (0.00s)
    issues_test.go:25:
                Error Trace:    /Users/williammartin/workspace/github-mcp-server/pkg/github/issues_test.go:25
                Error:          Received unexpected error:
                                tool schema for get_issue has changed unexpectedly:
                                @ ["annotations","title"]
                                - "Get issue details"
                                + "Get isse details"

                                run with `UPDATE_TOOLSNAPS=true` if this is expected
                Test:           Test_GetIssue
FAIL

Future Thoughts

Like with the desire to produce README's automatically from tool schemas, it would be better if there were a single data structure representing our tools, and then we could iterate that rather than relying on remembering to add the toolsnap call in each test.

@Copilot Copilot AI review requested due to automatic review settings June 18, 2025 08:26
@williammartin williammartin requested a review from a team as a code owner June 18, 2025 08:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Backfill toolsnaps invocations into all GitHub tool tests and generate corresponding snapshot files to catch unintended schema changes.

  • Insert require.NoError(t, toolsnaps.Test(...)) in every tool test.
  • Add a snapshot file under pkg/github/__toolsnaps__/ for each tool.
  • Update the toolsnaps library’s error message to include instructions for updating snapshots.

Reviewed Changes

Copilot reviewed 55 out of 55 changed files in this pull request and generated no comments.

File Description
internal/toolsnaps/toolsnaps.go Augment error message to suggest UPDATE_TOOLSNAPS=true.
pkg/github/*_test.go Invoke toolsnaps.Test in each tool’s test.
pkg/github/toolsnaps/*.snap New snapshot files for every tool schema.
Comments suppressed due to low confidence (2)

pkg/github/search_test.go:21

  • The call to require.NoError is unqualified because the require package isn't imported. Add import "github.com/stretchr/testify/require" to avoid compile errors.
	require.NoError(t, toolsnaps.Test(tool.Name, tool))

pkg/github/pullrequests_test.go:932

  • Variable tool is undefined in this scope (only handler was assigned). Capture the tool return value before using it, e.g. tool, handler := UpdatePullRequestBranch(...).
			require.NoError(t, toolsnaps.Test(tool.Name, tool))

@williammartin williammartin force-pushed the wm/toolsnap-every-tool branch from 522b2b1 to 40ab680 Compare June 18, 2025 08:31
@williammartin williammartin merged commit 846fac6 into main Jun 18, 2025
16 checks passed
@williammartin williammartin deleted the wm/toolsnap-every-tool branch June 18, 2025 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants