CreateRepository creates a tool to create a new GitHub repository.
(t translations.TranslationHelperFunc)
| 574 | |
| 575 | // CreateRepository creates a tool to create a new GitHub repository. |
| 576 | func CreateRepository(t translations.TranslationHelperFunc) inventory.ServerTool { |
| 577 | return NewTool( |
| 578 | ToolsetMetadataRepos, |
| 579 | mcp.Tool{ |
| 580 | Name: "create_repository", |
| 581 | Description: t("TOOL_CREATE_REPOSITORY_DESCRIPTION", "Create a new GitHub repository in your account or specified organization"), |
| 582 | Annotations: &mcp.ToolAnnotations{ |
| 583 | Title: t("TOOL_CREATE_REPOSITORY_USER_TITLE", "Create repository"), |
| 584 | ReadOnlyHint: false, |
| 585 | }, |
| 586 | InputSchema: &jsonschema.Schema{ |
| 587 | Type: "object", |
| 588 | Properties: map[string]*jsonschema.Schema{ |
| 589 | "name": { |
| 590 | Type: "string", |
| 591 | Description: "Repository name", |
| 592 | }, |
| 593 | "description": { |
| 594 | Type: "string", |
| 595 | Description: "Repository description", |
| 596 | }, |
| 597 | "organization": { |
| 598 | Type: "string", |
| 599 | Description: "Organization to create the repository in (omit to create in your personal account)", |
| 600 | }, |
| 601 | "private": { |
| 602 | Type: "boolean", |
| 603 | Description: "Whether the repository should be private. Defaults to true (private) when omitted.", |
| 604 | Default: json.RawMessage("true"), |
| 605 | }, |
| 606 | "autoInit": { |
| 607 | Type: "boolean", |
| 608 | Description: "Initialize with README", |
| 609 | }, |
| 610 | }, |
| 611 | Required: []string{"name"}, |
| 612 | }, |
| 613 | }, |
| 614 | []scopes.Scope{scopes.Repo}, |
| 615 | func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { |
| 616 | name, err := RequiredParam[string](args, "name") |
| 617 | if err != nil { |
| 618 | return utils.NewToolResultError(err.Error()), nil, nil |
| 619 | } |
| 620 | description, err := OptionalParam[string](args, "description") |
| 621 | if err != nil { |
| 622 | return utils.NewToolResultError(err.Error()), nil, nil |
| 623 | } |
| 624 | organization, err := OptionalParam[string](args, "organization") |
| 625 | if err != nil { |
| 626 | return utils.NewToolResultError(err.Error()), nil, nil |
| 627 | } |
| 628 | private, err := OptionalBoolParamWithDefault(args, "private", true) |
| 629 | if err != nil { |
| 630 | return utils.NewToolResultError(err.Error()), nil, nil |
| 631 | } |
| 632 | autoInit, err := OptionalParam[bool](args, "autoInit") |
| 633 | if err != nil { |