Skip to content

Commit 1b42ab9

Browse files
committed
Add tool annotations to server-github
Add readOnlyHint, destructiveHint, idempotentHint, and openWorldHint annotations to all 26 tools in the GitHub MCP server. Read operations (get, list, search) are marked read-only and idempotent. Write operations (create, update, push) are marked non-read-only. merge_pull_request is marked destructive since merges are irreversible. All tools are marked openWorldHint since they interact with GitHub's API. Closes #3399
1 parent e247123 commit 1b42ab9

1 file changed

Lines changed: 170 additions & 14 deletions

File tree

src/github/index.ts

Lines changed: 170 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,131 +75,287 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
7575
name: "create_or_update_file",
7676
description: "Create or update a single file in a GitHub repository",
7777
inputSchema: zodToJsonSchema(files.CreateOrUpdateFileSchema),
78+
annotations: {
79+
readOnlyHint: false,
80+
destructiveHint: false,
81+
idempotentHint: true,
82+
openWorldHint: true,
83+
},
7884
},
7985
{
8086
name: "search_repositories",
8187
description: "Search for GitHub repositories",
8288
inputSchema: zodToJsonSchema(repository.SearchRepositoriesSchema),
89+
annotations: {
90+
readOnlyHint: true,
91+
destructiveHint: false,
92+
idempotentHint: true,
93+
openWorldHint: true,
94+
},
8395
},
8496
{
8597
name: "create_repository",
8698
description: "Create a new GitHub repository in your account",
8799
inputSchema: zodToJsonSchema(repository.CreateRepositoryOptionsSchema),
100+
annotations: {
101+
readOnlyHint: false,
102+
destructiveHint: false,
103+
idempotentHint: false,
104+
openWorldHint: true,
105+
},
88106
},
89107
{
90108
name: "get_file_contents",
91109
description: "Get the contents of a file or directory from a GitHub repository",
92110
inputSchema: zodToJsonSchema(files.GetFileContentsSchema),
111+
annotations: {
112+
readOnlyHint: true,
113+
destructiveHint: false,
114+
idempotentHint: true,
115+
openWorldHint: true,
116+
},
93117
},
94118
{
95119
name: "push_files",
96120
description: "Push multiple files to a GitHub repository in a single commit",
97121
inputSchema: zodToJsonSchema(files.PushFilesSchema),
122+
annotations: {
123+
readOnlyHint: false,
124+
destructiveHint: false,
125+
idempotentHint: false,
126+
openWorldHint: true,
127+
},
98128
},
99129
{
100130
name: "create_issue",
101131
description: "Create a new issue in a GitHub repository",
102132
inputSchema: zodToJsonSchema(issues.CreateIssueSchema),
133+
annotations: {
134+
readOnlyHint: false,
135+
destructiveHint: false,
136+
idempotentHint: false,
137+
openWorldHint: true,
138+
},
103139
},
104140
{
105141
name: "create_pull_request",
106142
description: "Create a new pull request in a GitHub repository",
107143
inputSchema: zodToJsonSchema(pulls.CreatePullRequestSchema),
144+
annotations: {
145+
readOnlyHint: false,
146+
destructiveHint: false,
147+
idempotentHint: false,
148+
openWorldHint: true,
149+
},
108150
},
109151
{
110152
name: "fork_repository",
111153
description: "Fork a GitHub repository to your account or specified organization",
112154
inputSchema: zodToJsonSchema(repository.ForkRepositorySchema),
155+
annotations: {
156+
readOnlyHint: false,
157+
destructiveHint: false,
158+
idempotentHint: true,
159+
openWorldHint: true,
160+
},
113161
},
114162
{
115163
name: "create_branch",
116164
description: "Create a new branch in a GitHub repository",
117165
inputSchema: zodToJsonSchema(branches.CreateBranchSchema),
166+
annotations: {
167+
readOnlyHint: false,
168+
destructiveHint: false,
169+
idempotentHint: true,
170+
openWorldHint: true,
171+
},
118172
},
119173
{
120174
name: "list_commits",
121175
description: "Get list of commits of a branch in a GitHub repository",
122-
inputSchema: zodToJsonSchema(commits.ListCommitsSchema)
176+
inputSchema: zodToJsonSchema(commits.ListCommitsSchema),
177+
annotations: {
178+
readOnlyHint: true,
179+
destructiveHint: false,
180+
idempotentHint: true,
181+
openWorldHint: true,
182+
},
123183
},
124184
{
125185
name: "list_issues",
126186
description: "List issues in a GitHub repository with filtering options",
127-
inputSchema: zodToJsonSchema(issues.ListIssuesOptionsSchema)
187+
inputSchema: zodToJsonSchema(issues.ListIssuesOptionsSchema),
188+
annotations: {
189+
readOnlyHint: true,
190+
destructiveHint: false,
191+
idempotentHint: true,
192+
openWorldHint: true,
193+
},
128194
},
129195
{
130196
name: "update_issue",
131197
description: "Update an existing issue in a GitHub repository",
132-
inputSchema: zodToJsonSchema(issues.UpdateIssueOptionsSchema)
198+
inputSchema: zodToJsonSchema(issues.UpdateIssueOptionsSchema),
199+
annotations: {
200+
readOnlyHint: false,
201+
destructiveHint: false,
202+
idempotentHint: true,
203+
openWorldHint: true,
204+
},
133205
},
134206
{
135207
name: "add_issue_comment",
136208
description: "Add a comment to an existing issue",
137-
inputSchema: zodToJsonSchema(issues.IssueCommentSchema)
209+
inputSchema: zodToJsonSchema(issues.IssueCommentSchema),
210+
annotations: {
211+
readOnlyHint: false,
212+
destructiveHint: false,
213+
idempotentHint: false,
214+
openWorldHint: true,
215+
},
138216
},
139217
{
140218
name: "search_code",
141219
description: "Search for code across GitHub repositories",
142220
inputSchema: zodToJsonSchema(search.SearchCodeSchema),
221+
annotations: {
222+
readOnlyHint: true,
223+
destructiveHint: false,
224+
idempotentHint: true,
225+
openWorldHint: true,
226+
},
143227
},
144228
{
145229
name: "search_issues",
146230
description: "Search for issues and pull requests across GitHub repositories",
147231
inputSchema: zodToJsonSchema(search.SearchIssuesSchema),
232+
annotations: {
233+
readOnlyHint: true,
234+
destructiveHint: false,
235+
idempotentHint: true,
236+
openWorldHint: true,
237+
},
148238
},
149239
{
150240
name: "search_users",
151241
description: "Search for users on GitHub",
152242
inputSchema: zodToJsonSchema(search.SearchUsersSchema),
243+
annotations: {
244+
readOnlyHint: true,
245+
destructiveHint: false,
246+
idempotentHint: true,
247+
openWorldHint: true,
248+
},
153249
},
154250
{
155251
name: "get_issue",
156252
description: "Get details of a specific issue in a GitHub repository.",
157-
inputSchema: zodToJsonSchema(issues.GetIssueSchema)
253+
inputSchema: zodToJsonSchema(issues.GetIssueSchema),
254+
annotations: {
255+
readOnlyHint: true,
256+
destructiveHint: false,
257+
idempotentHint: true,
258+
openWorldHint: true,
259+
},
158260
},
159261
{
160262
name: "get_pull_request",
161263
description: "Get details of a specific pull request",
162-
inputSchema: zodToJsonSchema(pulls.GetPullRequestSchema)
264+
inputSchema: zodToJsonSchema(pulls.GetPullRequestSchema),
265+
annotations: {
266+
readOnlyHint: true,
267+
destructiveHint: false,
268+
idempotentHint: true,
269+
openWorldHint: true,
270+
},
163271
},
164272
{
165273
name: "list_pull_requests",
166274
description: "List and filter repository pull requests",
167-
inputSchema: zodToJsonSchema(pulls.ListPullRequestsSchema)
275+
inputSchema: zodToJsonSchema(pulls.ListPullRequestsSchema),
276+
annotations: {
277+
readOnlyHint: true,
278+
destructiveHint: false,
279+
idempotentHint: true,
280+
openWorldHint: true,
281+
},
168282
},
169283
{
170284
name: "create_pull_request_review",
171285
description: "Create a review on a pull request",
172-
inputSchema: zodToJsonSchema(pulls.CreatePullRequestReviewSchema)
286+
inputSchema: zodToJsonSchema(pulls.CreatePullRequestReviewSchema),
287+
annotations: {
288+
readOnlyHint: false,
289+
destructiveHint: false,
290+
idempotentHint: false,
291+
openWorldHint: true,
292+
},
173293
},
174294
{
175295
name: "merge_pull_request",
176296
description: "Merge a pull request",
177-
inputSchema: zodToJsonSchema(pulls.MergePullRequestSchema)
297+
inputSchema: zodToJsonSchema(pulls.MergePullRequestSchema),
298+
annotations: {
299+
readOnlyHint: false,
300+
destructiveHint: true,
301+
idempotentHint: false,
302+
openWorldHint: true,
303+
},
178304
},
179305
{
180306
name: "get_pull_request_files",
181307
description: "Get the list of files changed in a pull request",
182-
inputSchema: zodToJsonSchema(pulls.GetPullRequestFilesSchema)
308+
inputSchema: zodToJsonSchema(pulls.GetPullRequestFilesSchema),
309+
annotations: {
310+
readOnlyHint: true,
311+
destructiveHint: false,
312+
idempotentHint: true,
313+
openWorldHint: true,
314+
},
183315
},
184316
{
185317
name: "get_pull_request_status",
186318
description: "Get the combined status of all status checks for a pull request",
187-
inputSchema: zodToJsonSchema(pulls.GetPullRequestStatusSchema)
319+
inputSchema: zodToJsonSchema(pulls.GetPullRequestStatusSchema),
320+
annotations: {
321+
readOnlyHint: true,
322+
destructiveHint: false,
323+
idempotentHint: true,
324+
openWorldHint: true,
325+
},
188326
},
189327
{
190328
name: "update_pull_request_branch",
191329
description: "Update a pull request branch with the latest changes from the base branch",
192-
inputSchema: zodToJsonSchema(pulls.UpdatePullRequestBranchSchema)
330+
inputSchema: zodToJsonSchema(pulls.UpdatePullRequestBranchSchema),
331+
annotations: {
332+
readOnlyHint: false,
333+
destructiveHint: false,
334+
idempotentHint: true,
335+
openWorldHint: true,
336+
},
193337
},
194338
{
195339
name: "get_pull_request_comments",
196340
description: "Get the review comments on a pull request",
197-
inputSchema: zodToJsonSchema(pulls.GetPullRequestCommentsSchema)
341+
inputSchema: zodToJsonSchema(pulls.GetPullRequestCommentsSchema),
342+
annotations: {
343+
readOnlyHint: true,
344+
destructiveHint: false,
345+
idempotentHint: true,
346+
openWorldHint: true,
347+
},
198348
},
199349
{
200350
name: "get_pull_request_reviews",
201351
description: "Get the reviews on a pull request",
202-
inputSchema: zodToJsonSchema(pulls.GetPullRequestReviewsSchema)
352+
inputSchema: zodToJsonSchema(pulls.GetPullRequestReviewsSchema),
353+
annotations: {
354+
readOnlyHint: true,
355+
destructiveHint: false,
356+
idempotentHint: true,
357+
openWorldHint: true,
358+
},
203359
}
204360
],
205361
};

0 commit comments

Comments
 (0)