Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Conform list tools#90

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
williammartin merged 2 commits intomainfromwm/list-tools-conformance
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
40 changes: 20 additions & 20 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -150,7 +150,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
- `direction`: Sort direction ('asc', 'desc') (string, optional)
- `since`: Filter by date (ISO 8601 timestamp) (string, optional)
- `page`: Page number (number, optional)
- `per_page`: Results per page (number, optional)
- `perPage`: Results per page (number, optional)

- **update_issue** - Update an existing issue in a GitHub repository

Expand All@@ -177,7 +177,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description

- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)
- `pull_number`: Pull request number (number, required)
- `pullNumber`: Pull request number (number, required)

- **list_pull_requests** - List and filter repository pull requests

Expand All@@ -186,14 +186,14 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
- `state`: PR state (string, optional)
- `sort`: Sort field (string, optional)
- `direction`: Sort direction (string, optional)
- `per_page`: Results per page (number, optional)
- `perPage`: Results per page (number, optional)
- `page`: Page number (number, optional)

- **merge_pull_request** - Merge a pull request

- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)
- `pull_number`: Pull request number (number, required)
- `pullNumber`: Pull request number (number, required)
- `commit_title`: Title for the merge commit (string, optional)
- `commit_message`: Message for the merge commit (string, optional)
- `merge_method`: Merge method (string, optional)
Expand All@@ -202,41 +202,41 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description

- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)
- `pull_number`: Pull request number (number, required)
- `pullNumber`: Pull request number (number, required)

- **get_pull_request_status** - Get the combined status of all status checks for a pull request

- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)
- `pull_number`: Pull request number (number, required)
- `pullNumber`: Pull request number (number, required)

- **update_pull_request_branch** - Update a pull request branch with the latest changes from the base branch

- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)
- `pull_number`: Pull request number (number, required)
- `expected_head_sha`: The expected SHA of the pull request's HEAD ref (string, optional)
- `pullNumber`: Pull request number (number, required)
- `expectedHeadSha`: The expected SHA of the pull request's HEAD ref (string, optional)

- **get_pull_request_comments** - Get the review comments on a pull request

- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)
- `pull_number`: Pull request number (number, required)
- `pullNumber`: Pull request number (number, required)

- **get_pull_request_reviews** - Get the reviews on a pull request

- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)
- `pull_number`: Pull request number (number, required)
- `pullNumber`: Pull request number (number, required)

- **create_pull_request_review** - Create a review on a pull request review

- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)
- `pull_number`: Pull request number (number, required)
- `pullNumber`: Pull request number (number, required)
- `body`: Review comment text (string, optional)
- `event`: Review action ('APPROVE', 'REQUEST_CHANGES', 'COMMENT') (string, required)
- `commit_id`: SHA of commit to review (string, optional)
- `commitId`: SHA of commit to review (string, optional)
- `comments`: Line-specific comments array of objects, each object with path (string), position (number), and body (string) (array, optional)

- **create_pull_request** - Create a new pull request
Expand DownExpand Up@@ -276,14 +276,14 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
- `sort`: Sort field (string, optional)
- `order`: Sort order (string, optional)
- `page`: Page number (number, optional)
- `per_page`: Results per page (number, optional)
- `perPage`: Results per page (number, optional)

- **create_repository** - Create a new GitHub repository

- `name`: Repository name (string, required)
- `description`: Repository description (string, optional)
- `private`: Whether the repository is private (boolean, optional)
- `auto_init`: Auto-initialize with README (boolean, optional)
- `autoInit`: Auto-initialize with README (boolean, optional)

- **get_file_contents** - Get contents of a file or directory

Expand DownExpand Up@@ -311,7 +311,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
- `sha`: Branch name, tag, or commit SHA (string, optional)
- `path`: Only commits containing this file path (string, optional)
- `page`: Page number (number, optional)
- `per_page`: Results per page (number, optional)
- `perPage`: Results per page (number, optional)

### Search

Expand All@@ -321,22 +321,22 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
- `sort`: Sort field (string, optional)
- `order`: Sort order (string, optional)
- `page`: Page number (number, optional)
- `per_page`: Results per page (number, optional)
- `perPage`: Results per page (number, optional)

- **search_users** - Search for GitHub users
- `query`: Search query (string, required)
- `sort`: Sort field (string, optional)
- `order`: Sort order (string, optional)
- `page`: Page number (number, optional)
- `per_page`: Results per page (number, optional)
- `perPage`: Results per page (number, optional)

### Code Scanning

- **get_code_scanning_alert** - Get a code scanning alert

- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)
- `alert_number`: Alert number (number, required)
- `alertNumber`: Alert number (number, required)

- **list_code_scanning_alerts** - List code scanning alerts for a repository
- `owner`: Repository owner (string, required)
Expand DownExpand Up@@ -391,11 +391,11 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
- **Get Repository Content for a Specific Pull Request**
Retrieves the content of a repository at a specific path for a given pull request.

- **Template**: `repo://{owner}/{repo}/refs/pull/{pr_number}/head/contents{/path*}`
- **Template**: `repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*}`
- **Parameters**:
- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)
- `pr_number`: Pull request number (string, required)
- `prNumber`: Pull request number (string, required)
- `path`: File or directory path (string, optional)

## License
Expand Down
2 changes: 1 addition & 1 deletioncmd/mcpcurl/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,7 +72,7 @@ Use "mcpcurl tools [command] --help" for more information about a command.
Get help for a specific tool:

```bash
% ./mcpcurl --stdio-server-cmd "docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN mcp/github" tools get_issue --help
% ./mcpcurl --stdio-server-cmd "docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN mcp/github" tools get_issue --help
Get details of a specific issue in a GitHub repository.

Usage:
Expand Down
143 changes: 108 additions & 35 deletionsconformance/conformance_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@ import (
"bufio"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"os"
Expand All@@ -17,6 +18,8 @@ import (
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/stdcopy"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/stretchr/testify/require"
)

Expand DownExpand Up@@ -130,16 +133,19 @@ func TestCapabilities(t *testing.T) {
anthropicServer := start(t, anthropic)
githubServer := start(t, github)

req := newInitializeRequest(
initializeRequestParams{
req := initializeRequest{
JSONRPC: "2.0",
ID: 1,
Method: "initialize",
Params: initializeParams{
ProtocolVersion: "2025-03-26",
Capabilities: clientCapabilities{},
ClientInfo: clientInfo{
Name: "ConformanceTest",
Version: "0.0.1",
},
},
)
}

require.NoError(t, anthropicServer.send(req))

Expand DownExpand Up@@ -227,6 +233,69 @@ func diffNonNilFields(a, b interface{}, path string) string {
return sb.String()
}

func TestListTools(t *testing.T) {
anthropicServer := start(t, anthropic)
githubServer := start(t, github)

req := listToolsRequest{
JSONRPC: "2.0",
ID: 1,
Method: "tools/list",
}

require.NoError(t, anthropicServer.send(req))

var anthropicListToolsResponse listToolsResponse
require.NoError(t, anthropicServer.receive(&anthropicListToolsResponse))

require.NoError(t, githubServer.send(req))

var ghListToolsResponse listToolsResponse
require.NoError(t, githubServer.receive(&ghListToolsResponse))

require.NoError(t, isToolListSubset(anthropicListToolsResponse.Result, ghListToolsResponse.Result), "expected the github list tools response to be a subset of the anthropic list tools response")
}

func isToolListSubset(subset, superset listToolsResult) error {
// Build a map from tool name to Tool from the superset
supersetMap := make(map[string]tool)
for _, tool := range superset.Tools {
supersetMap[tool.Name] = tool
}

var err error
for _, tool := range subset.Tools {
sup, ok := supersetMap[tool.Name]
if !ok {
return fmt.Errorf("tool %q not found in superset", tool.Name)
}

// Intentionally ignore the description fields because there are lots of slight differences.
// if tool.Description != sup.Description {
// return fmt.Errorf("description mismatch for tool %q, got %q expected %q", tool.Name, tool.Description, sup.Description)
// }

// Ignore any description fields within the input schema properties for the same reason
ignoreDescOpt := cmp.FilterPath(func(p cmp.Path) bool {
// Look for a field named "Properties" somewhere in the path
for _, ps := range p {
if sf, ok := ps.(cmp.StructField); ok && sf.Name() == "Properties" {
return true
}
}
return false
}, cmpopts.IgnoreMapEntries(func(k string, _ any) bool {
return k == "description"
}))

if diff := cmp.Diff(tool.InputSchema, sup.InputSchema, ignoreDescOpt); diff != "" {
Copy link
Preview

CopilotAIApr 3, 2025

Choose a reason for hiding this comment

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

The current subset check using cmp.Diff requires an exact match between input schemas. To correctly enforce that the GitHub response is a subset of the Anthropic response, consider modifying this comparison to validate that every key-value pair in the GitHub schema exists in the Anthropic schema, allowing additional properties in the latter.

Copilot uses AI. Check for mistakes.

err = errors.Join(err, fmt.Errorf("inputSchema mismatch for tool %q:\n%s", tool.Name, diff))
}
}

return err
}

type serverStartResult struct {
server server
err error
Expand DownExpand Up@@ -274,48 +343,39 @@ func (s server) receive(res response) error {
return res.unmarshal(line)
}

type request interface {
marshal() ([]byte, error)
}

type response interface {
unmarshal([]byte) error
}

type jsonRPRCRequest[params any] struct {
JSONRPC string `json:"jsonrpc"`
ID int `json:"id"`
Method string `json:"method"`
Params params `json:"params"`
}

func (r jsonRPRCRequest[any]) marshal() ([]byte, error) {
return json.Marshal(r)
}

type jsonRPRCResponse[result any] struct {
JSONRPC string `json:"jsonrpc"`
ID int `json:"id"`
Method string `json:"method"`
Result result `json:"result"`
}

type request interface {
marshal() ([]byte, error)
}

type response interface {
unmarshal([]byte) error
}

func newInitializeRequest(params initializeRequestParams) initializeRequest {
return initializeRequest{
jsonRPRCRequest: jsonRPRCRequest[initializeRequestParams]{
JSONRPC: "2.0",
ID: 1,
Method: "initialize",
Params: params,
},
}
}

type initializeRequest struct {
jsonRPRCRequest[initializeRequestParams]
func (r *jsonRPRCResponse[any]) unmarshal(b []byte) error {
return json.Unmarshal(b, r)
}

func (r initializeRequest) marshal() ([]byte, error) {
return json.Marshal(r)
}
type initializeRequest = jsonRPRCRequest[initializeParams]

typeinitializeRequestParams struct {
typeinitializeParams struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities clientCapabilities `json:"capabilities"`
ClientInfo clientInfo `json:"clientInfo"`
Expand All@@ -328,13 +388,7 @@ type clientInfo struct {
Version string `json:"version"`
}

type initializeResponse struct {
jsonRPRCResponse[initializeResult]
}

func (r *initializeResponse) unmarshal(b []byte) error {
return json.Unmarshal(b, r)
}
type initializeResponse = jsonRPRCResponse[initializeResult]

type initializeResult struct {
ProtocolVersion string `json:"protocolVersion"`
Expand All@@ -360,3 +414,22 @@ type serverInfo struct {
Name string `json:"name"`
Version string `json:"version"`
}

type listToolsRequest = jsonRPRCRequest[struct{}]

type listToolsResponse = jsonRPRCResponse[listToolsResult]

type listToolsResult struct {
Tools []tool `json:"tools"`
}
type tool struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
InputSchema inputSchema `json:"inputSchema"`
}

type inputSchema struct {
Type string `json:"type"`
Properties map[string]any `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
}
1 change: 1 addition & 0 deletionsgo.mod
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,7 @@ go 1.23.7
require (
github.com/aws/smithy-go v1.22.3
github.com/docker/docker v28.0.4+incompatible
github.com/google/go-cmp v0.7.0
github.com/google/go-github/v69 v69.2.0
github.com/mark3labs/mcp-go v0.18.0
github.com/migueleliasweb/go-github-mock v1.1.0
Expand Down
4 changes: 2 additions & 2 deletionspkg/github/code_scanning.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func getCodeScanningAlert(client *github.Client, t translations.TranslationHelpe
mcp.Required(),
mcp.Description("The name of the repository."),
),
mcp.WithNumber("alert_number",
mcp.WithNumber("alertNumber",
mcp.Required(),
mcp.Description("The number of the alert."),
),
Expand All@@ -38,7 +38,7 @@ func getCodeScanningAlert(client *github.Client, t translations.TranslationHelpe
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
alertNumber, err := requiredInt(request, "alert_number")
alertNumber, err := requiredInt(request, "alertNumber")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp