Skip to content

Commit 7880982

Browse files
committed
servers: make tool call result spec compatible
1 parent 87082db commit 7880982

File tree

5 files changed

+269
-329
lines changed

5 files changed

+269
-329
lines changed

src/github/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
529529
case "fork_repository": {
530530
const args = ForkRepositorySchema.parse(request.params.arguments);
531531
const fork = await forkRepository(args.owner, args.repo, args.organization);
532-
return { toolResult: fork };
532+
return { content: [{ type: "text", text: JSON.stringify(fork, null, 2) }] };
533533
}
534534

535535
case "create_branch": {
@@ -562,25 +562,25 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
562562
sha
563563
});
564564

565-
return { toolResult: branch };
565+
return { content: [{ type: "text", text: JSON.stringify(branch, null, 2) }] };
566566
}
567567

568568
case "search_repositories": {
569569
const args = SearchRepositoriesSchema.parse(request.params.arguments);
570570
const results = await searchRepositories(args.query, args.page, args.perPage);
571-
return { toolResult: results };
571+
return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }] };
572572
}
573573

574574
case "create_repository": {
575575
const args = CreateRepositorySchema.parse(request.params.arguments);
576576
const repository = await createRepository(args);
577-
return { toolResult: repository };
577+
return { content: [{ type: "text", text: JSON.stringify(repository, null, 2) }] };
578578
}
579579

580580
case "get_file_contents": {
581581
const args = GetFileContentsSchema.parse(request.params.arguments);
582582
const contents = await getFileContents(args.owner, args.repo, args.path, args.branch);
583-
return { toolResult: contents };
583+
return { content: [{ type: "text", text: JSON.stringify(contents, null, 2) }] };
584584
}
585585

586586
case "create_or_update_file": {
@@ -594,7 +594,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
594594
args.branch,
595595
args.sha
596596
);
597-
return { toolResult: result };
597+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
598598
}
599599

600600
case "push_files": {
@@ -606,21 +606,21 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
606606
args.files,
607607
args.message
608608
);
609-
return { toolResult: result };
609+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
610610
}
611611

612612
case "create_issue": {
613613
const args = CreateIssueSchema.parse(request.params.arguments);
614614
const { owner, repo, ...options } = args;
615615
const issue = await createIssue(owner, repo, options);
616-
return { toolResult: issue };
616+
return { content: [{ type: "text", text: JSON.stringify(issue, null, 2) }] };
617617
}
618618

619619
case "create_pull_request": {
620620
const args = CreatePullRequestSchema.parse(request.params.arguments);
621621
const { owner, repo, ...options } = args;
622622
const pullRequest = await createPullRequest(owner, repo, options);
623-
return { toolResult: pullRequest };
623+
return { content: [{ type: "text", text: JSON.stringify(pullRequest, null, 2) }] };
624624
}
625625

626626
default:

src/gitlab/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
437437
case "fork_repository": {
438438
const args = ForkRepositorySchema.parse(request.params.arguments);
439439
const fork = await forkProject(args.project_id, args.namespace);
440-
return { toolResult: fork };
440+
return { content: [{ type: "text", text: JSON.stringify(fork, null, 2) }] };
441441
}
442442

443443
case "create_branch": {
@@ -452,25 +452,25 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
452452
ref
453453
});
454454

455-
return { toolResult: branch };
455+
return { content: [{ type: "text", text: JSON.stringify(branch, null, 2) }] };
456456
}
457457

458458
case "search_repositories": {
459459
const args = SearchRepositoriesSchema.parse(request.params.arguments);
460460
const results = await searchProjects(args.search, args.page, args.per_page);
461-
return { toolResult: results };
461+
return { content: [{ type: "text", text: JSON.stringify(results, null, 2) }] };
462462
}
463463

464464
case "create_repository": {
465465
const args = CreateRepositorySchema.parse(request.params.arguments);
466466
const repository = await createRepository(args);
467-
return { toolResult: repository };
467+
return { content: [{ type: "text", text: JSON.stringify(repository, null, 2) }] };
468468
}
469469

470470
case "get_file_contents": {
471471
const args = GetFileContentsSchema.parse(request.params.arguments);
472472
const contents = await getFileContents(args.project_id, args.file_path, args.ref);
473-
return { toolResult: contents };
473+
return { content: [{ type: "text", text: JSON.stringify(contents, null, 2) }] };
474474
}
475475

476476
case "create_or_update_file": {
@@ -483,7 +483,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
483483
args.branch,
484484
args.previous_path
485485
);
486-
return { toolResult: result };
486+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
487487
}
488488

489489
case "push_files": {
@@ -494,21 +494,21 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
494494
args.branch,
495495
args.files.map(f => ({ path: f.file_path, content: f.content }))
496496
);
497-
return { toolResult: result };
497+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
498498
}
499499

500500
case "create_issue": {
501501
const args = CreateIssueSchema.parse(request.params.arguments);
502502
const { project_id, ...options } = args;
503503
const issue = await createIssue(project_id, options);
504-
return { toolResult: issue };
504+
return { content: [{ type: "text", text: JSON.stringify(issue, null, 2) }] };
505505
}
506506

507507
case "create_merge_request": {
508508
const args = CreateMergeRequestSchema.parse(request.params.arguments);
509509
const { project_id, ...options } = args;
510510
const mergeRequest = await createMergeRequest(project_id, options);
511-
return { toolResult: mergeRequest };
511+
return { content: [{ type: "text", text: JSON.stringify(mergeRequest, null, 2) }] };
512512
}
513513

514514
default:

0 commit comments

Comments
 (0)