Skip to content

Commit

Permalink
fix: Correctly structure tool responses
Browse files Browse the repository at this point in the history
Refactored list_issues, update_issue, add_issue_comment, and get_issue
tools to return their responses in the correct MCP `content` structure following the spec https://github.com/modelcontextprotocol/specification/blob/main/schema/schema.json#L80
  • Loading branch information
apappascs committed Dec 22, 2024
1 parent 0e7d79c commit 8cd5238
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/github/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -978,21 +978,21 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
const args = ListIssuesOptionsSchema.parse(request.params.arguments);
const { owner, repo, ...options } = args;
const issues = await listIssues(owner, repo, options);
return { toolResult: issues };
return { content: [{ type: "text", text: JSON.stringify(issues, null, 2) }] };
}

case "update_issue": {
const args = UpdateIssueOptionsSchema.parse(request.params.arguments);
const { owner, repo, issue_number, ...options } = args;
const issue = await updateIssue(owner, repo, issue_number, options);
return { toolResult: issue };
return { content: [{ type: "text", text: JSON.stringify(issue, null, 2) }] };
}

case "add_issue_comment": {
const args = IssueCommentSchema.parse(request.params.arguments);
const { owner, repo, issue_number, body } = args;
const comment = await addIssueComment(owner, repo, issue_number, body);
return { toolResult: comment };
return { content: [{ type: "text", text: JSON.stringify(comment, null, 2) }] };
}

case "list_commits": {
Expand All @@ -1008,7 +1008,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
issue_number: z.number()
}).parse(request.params.arguments);
const issue = await getIssue(args.owner, args.repo, args.issue_number);
return { toolResult: issue };
return { content: [{ type: "text", text: JSON.stringify(issue, null, 2) }] };
}

default:
Expand Down

0 comments on commit 8cd5238

Please sign in to comment.