Skip to content

Commit 0e5c67a

Browse files
authored
Merge branch 'main' into dependabot/go_modules/github.com/mark3labs/mcp-go-0.40.0
2 parents 39e1339 + abf7c47 commit 0e5c67a

File tree

13 files changed

+913
-55
lines changed

13 files changed

+913
-55
lines changed

.github/workflows/docker-publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ on:
1414
tags: ["v*.*.*"]
1515
pull_request:
1616
branches: ["main", "next"]
17+
workflow_dispatch:
18+
inputs:
19+
description:
20+
required: false
21+
description: "Description of the run."
22+
type: string
23+
default: "Manual run"
1724

1825
env:
1926
# Use docker.io for Docker Hub if empty
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Publish to MCP Registry
2+
3+
on:
4+
push:
5+
tags: ["v*"] # Triggers on version tags like v1.0.0
6+
workflow_dispatch: # Allow manual triggering
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write # Required for OIDC authentication
13+
contents: read
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v5
18+
19+
- name: Fetch tags
20+
run: git fetch --tags
21+
22+
- name: Install MCP Publisher
23+
run: |
24+
curl -L "https://github.com/modelcontextprotocol/registry/releases/download/v1.0.0/mcp-publisher_1.0.0_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher
25+
26+
- name: Update server.json version
27+
run: |
28+
if [[ "${{ github.ref_type }}" == "tag" ]]; then
29+
# Use the tag that triggered the workflow
30+
TAG_VERSION=$(echo "${{ github.ref_name }}" | sed 's/^v//')
31+
echo "Using triggered tag: ${{ github.ref_name }}"
32+
else
33+
# Fallback to latest tag (for manual triggers)
34+
LATEST_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$' | head -n 1)
35+
if [ -z "$LATEST_TAG" ]; then
36+
echo "❌ No release tag found. Cannot determine version."
37+
exit 1
38+
fi
39+
TAG_VERSION=$(echo "$LATEST_TAG" | sed 's/^v//')
40+
echo "Using latest tag: $LATEST_TAG"
41+
fi
42+
sed -i "s/\${VERSION}/$TAG_VERSION/g" server.json
43+
echo "Updated server.json version to $TAG_VERSION"
44+
45+
- name: Login to MCP Registry
46+
run: ./mcp-publisher login github-oidc
47+
48+
- name: Publish to MCP Registry
49+
run: ./mcp-publisher publish

README.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,19 @@ The following sets of tools are available (all are on by default):
658658

659659
<summary>Projects</summary>
660660

661+
- **get_project** - Get project
662+
- `owner`: If owner_type == user it is the handle for the GitHub user account. If owner_type == org it is the name of the organization. The name is not case sensitive. (string, required)
663+
- `owner_type`: Owner type (string, required)
664+
- `project_number`: The project's number (number, required)
665+
666+
- **list_project_fields** - List project fields
667+
- `owner`: If owner_type == user it is the handle for the GitHub user account. If owner_type == org it is the name of the organization. The name is not case sensitive. (string, required)
668+
- `owner_type`: Owner type (string, required)
669+
- `per_page`: Number of results per page (max 100, default: 30) (number, optional)
670+
- `projectNumber`: The project's number. (string, required)
671+
661672
- **list_projects** - List projects
662-
- `after`: Cursor for items after (forward pagination) (string, optional)
663-
- `before`: Cursor for items before (backwards pagination) (string, optional)
664-
- `owner`: If owner_type == user it is the handle for the GitHub user account. If owner_type == organization it is the name of the organization. The name is not case sensitive. (string, required)
673+
- `owner`: If owner_type == user it is the handle for the GitHub user account. If owner_type == org it is the name of the organization. The name is not case sensitive. (string, required)
665674
- `owner_type`: Owner type (string, required)
666675
- `per_page`: Number of results per page (max 100, default: 30) (number, optional)
667676
- `query`: Filter projects by a search query (matches title and description) (string, optional)
@@ -1017,6 +1026,17 @@ The following sets of tools are available (all are on by default):
10171026

10181027
</details>
10191028

1029+
<details>
1030+
1031+
<summary>Copilot Spaces</summary>
1032+
1033+
- **get_copilot_space** - Get Copilot Space
1034+
- `owner`: The owner of the space. (string, required)
1035+
- `name`: The name of the space. (string, required)
1036+
1037+
- **list_copilot_spaces** - List Copilot Spaces
1038+
</details>
1039+
10201040
#### Specifying Toolsets
10211041

10221042
To specify toolsets you want available to the LLM, you can pass an allow-list in two ways:

internal/ghmcp/server.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ func NewMCPServer(cfg MCPServerConfig) (*server.MCPServer, error) {
105105
},
106106
}
107107

108-
ghServer := github.NewServer(cfg.Version, server.WithHooks(hooks))
109-
110108
enabledToolsets := cfg.EnabledToolsets
111109
if cfg.DynamicToolsets {
112110
// filter "all" from the enabled toolsets
@@ -118,6 +116,14 @@ func NewMCPServer(cfg MCPServerConfig) (*server.MCPServer, error) {
118116
}
119117
}
120118

119+
// Generate instructions based on enabled toolsets
120+
instructions := github.GenerateInstructions(enabledToolsets)
121+
122+
ghServer := github.NewServer(cfg.Version,
123+
server.WithInstructions(instructions),
124+
server.WithHooks(hooks),
125+
)
126+
121127
getClient := func(_ context.Context) (*gogithub.Client, error) {
122128
return restClient, nil // closing over client
123129
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"annotations": {
3+
"title": "Get project",
4+
"readOnlyHint": true
5+
},
6+
"description": "Get Project for a user or org",
7+
"inputSchema": {
8+
"properties": {
9+
"owner": {
10+
"description": "If owner_type == user it is the handle for the GitHub user account. If owner_type == org it is the name of the organization. The name is not case sensitive.",
11+
"type": "string"
12+
},
13+
"owner_type": {
14+
"description": "Owner type",
15+
"enum": [
16+
"user",
17+
"org"
18+
],
19+
"type": "string"
20+
},
21+
"project_number": {
22+
"description": "The project's number",
23+
"type": "number"
24+
}
25+
},
26+
"required": [
27+
"project_number",
28+
"owner_type",
29+
"owner"
30+
],
31+
"type": "object"
32+
},
33+
"name": "get_project"
34+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"annotations": {
3+
"title": "List project fields",
4+
"readOnlyHint": true
5+
},
6+
"description": "List Project fields for a user or org",
7+
"inputSchema": {
8+
"properties": {
9+
"owner": {
10+
"description": "If owner_type == user it is the handle for the GitHub user account. If owner_type == org it is the name of the organization. The name is not case sensitive.",
11+
"type": "string"
12+
},
13+
"owner_type": {
14+
"description": "Owner type",
15+
"enum": [
16+
"user",
17+
"org"
18+
],
19+
"type": "string"
20+
},
21+
"per_page": {
22+
"description": "Number of results per page (max 100, default: 30)",
23+
"type": "number"
24+
},
25+
"projectNumber": {
26+
"description": "The project's number.",
27+
"type": "string"
28+
}
29+
},
30+
"required": [
31+
"owner_type",
32+
"owner",
33+
"projectNumber"
34+
],
35+
"type": "object"
36+
},
37+
"name": "list_project_fields"
38+
}

pkg/github/__toolsnaps__/list_projects.snap

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,18 @@
33
"title": "List projects",
44
"readOnlyHint": true
55
},
6-
"description": "List Projects for a user or organization",
6+
"description": "List Projects for a user or org",
77
"inputSchema": {
88
"properties": {
9-
"after": {
10-
"description": "Cursor for items after (forward pagination)",
11-
"type": "string"
12-
},
13-
"before": {
14-
"description": "Cursor for items before (backwards pagination)",
15-
"type": "string"
16-
},
179
"owner": {
18-
"description": "If owner_type == user it is the handle for the GitHub user account. If owner_type == organization it is the name of the organization. The name is not case sensitive.",
10+
"description": "If owner_type == user it is the handle for the GitHub user account. If owner_type == org it is the name of the organization. The name is not case sensitive.",
1911
"type": "string"
2012
},
2113
"owner_type": {
2214
"description": "Owner type",
2315
"enum": [
2416
"user",
25-
"organization"
17+
"org"
2618
],
2719
"type": "string"
2820
},

pkg/github/instructions.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package github
2+
3+
import (
4+
"os"
5+
"slices"
6+
"strings"
7+
)
8+
9+
// GenerateInstructions creates server instructions based on enabled toolsets
10+
func GenerateInstructions(enabledToolsets []string) string {
11+
// For testing - add a flag to disable instructions
12+
if os.Getenv("DISABLE_INSTRUCTIONS") == "true" {
13+
return "" // Baseline mode
14+
}
15+
16+
var instructions []string
17+
18+
// Core instruction - always included if context toolset enabled
19+
if slices.Contains(enabledToolsets, "context") {
20+
instructions = append(instructions, "Always call 'get_me' first to understand current user permissions and context.")
21+
}
22+
23+
// Individual toolset instructions
24+
for _, toolset := range enabledToolsets {
25+
if inst := getToolsetInstructions(toolset); inst != "" {
26+
instructions = append(instructions, inst)
27+
}
28+
}
29+
30+
// Base instruction with context management
31+
baseInstruction := `The GitHub MCP Server provides tools to interact with GitHub platform.
32+
33+
Tool selection guidance:
34+
1. Use 'list_*' tools for broad, simple retrieval and pagination of all items of a type (e.g., all issues, all PRs, all branches) with basic filtering.
35+
2. Use 'search_*' tools for targeted queries with specific criteria, keywords, or complex filters (e.g., issues with certain text, PRs by author, code containing functions).
36+
37+
Context management:
38+
1. Use pagination whenever possible with batches of 5-10 items.
39+
2. Use minimal_output parameter set to true if the full information is not needed to accomplish a task.`
40+
41+
allInstructions := []string{baseInstruction}
42+
allInstructions = append(allInstructions, instructions...)
43+
44+
return strings.Join(allInstructions, " ")
45+
}
46+
47+
// getToolsetInstructions returns specific instructions for individual toolsets
48+
func getToolsetInstructions(toolset string) string {
49+
switch toolset {
50+
case "pull_requests":
51+
return "## Pull Requests\n\nPR review workflow: Always use 'create_pending_pull_request_review' → 'add_comment_to_pending_review' → 'submit_pending_pull_request_review' for complex reviews with line-specific comments."
52+
case "issues":
53+
return "## Issues\n\nCheck 'list_issue_types' first for organizations to use proper issue types. Use 'search_issues' before creating new issues to avoid duplicates. Always set 'state_reason' when closing issues."
54+
case "discussions":
55+
return "## Discussions\n\nUse 'list_discussion_categories' to understand available categories before creating discussions. Filter by category for better organization."
56+
default:
57+
return ""
58+
}
59+
}
60+

0 commit comments

Comments
 (0)