Open Context Protocol is live! 🚀 Read the launch post

gitCreateCommit

Create a commit

Details

  • Method: POST
  • Path: /repos/{owner}/{repo}/git/commits
  • Operation ID: git/create-commit

Parameters

{
  "owner": {
    "description": "The account owner of the repository. The name is not case sensitive.",
    "required": true,
    "location": "path",
    "type": "string"
  },
  "repo": {
    "description": "The name of the repository without the `.git` extension. The name is not case sensitive.",
    "required": true,
    "location": "path",
    "type": "string"
  },
  "message": {
    "description": "The commit message",
    "required": true,
    "location": "body",
    "type": "string"
  },
  "tree": {
    "description": "The SHA of the tree object this commit points to",
    "required": true,
    "location": "body",
    "type": "string"
  },
  "parents": {
    "description": "The full SHAs of the commits that were the parents of this commit. If omitted or empty, the commit will be written as a root commit. For a single parent, an array of one SHA should be provided; for a merge commit, an array of more than one should be provided.",
    "required": false,
    "location": "body",
    "type": "array"
  },
  "author": {
    "description": "Information about the author of the commit. By default, the `author` will be the authenticated user and the current date. See the `author` and `committer` object below for details.",
    "required": false,
    "location": "body",
    "type": "object"
  },
  "committer": {
    "description": "Information about the person who is making the commit. By default, `committer` will use the information set in `author`. See the `author` and `committer` object below for details.",
    "required": false,
    "location": "body",
    "type": "object"
  },
  "signature": {
    "description": "The [PGP signature](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) of the commit. GitHub adds the signature to the `gpgsig` header of the created commit. For a commit signature to be verifiable by Git or GitHub, it must be an ASCII-armored detached PGP signature over the string commit as it would be written to the object database. To pass a `signature` parameter, you need to first manually create a valid PGP signature, which can be complicated. You may find it easier to [use the command line](https://git-scm.com/book/id/v2/Git-Tools-Signing-Your-Work) to create signed commits.",
    "required": false,
    "location": "body",
    "type": "string"
  }
}

Response Schema

{
  "title": "Git Commit",
  "description": "Low-level Git commit operations within a repository",
  "type": "object",
  "properties": {
    "sha": {
      "description": "SHA for the commit",
      "example": "7638417db6d59f3c431d3e1f261cc637155684cd",
      "type": "string"
    },
    "node_id": {
      "type": "string"
    },
    "url": {
      "type": "string",
      "format": "uri"
    },
    "author": {
      "description": "Identifying information for the git-user",
      "type": "object",
      "properties": {
        "date": {
          "description": "Timestamp of the commit",
          "example": "2014-08-09T08:02:04+12:00",
          "format": "date-time",
          "type": "string"
        },
        "email": {
          "type": "string",
          "description": "Git email address of the user",
          "example": "monalisa.octocat@example.com"
        },
        "name": {
          "description": "Name of the git user",
          "example": "Monalisa Octocat",
          "type": "string"
        }
      },
      "required": [
        "email",
        "name",
        "date"
      ]
    },
    "committer": {
      "description": "Identifying information for the git-user",
      "type": "object",
      "properties": {
        "date": {
          "description": "Timestamp of the commit",
          "example": "2014-08-09T08:02:04+12:00",
          "format": "date-time",
          "type": "string"
        },
        "email": {
          "type": "string",
          "description": "Git email address of the user",
          "example": "monalisa.octocat@example.com"
        },
        "name": {
          "description": "Name of the git user",
          "example": "Monalisa Octocat",
          "type": "string"
        }
      },
      "required": [
        "email",
        "name",
        "date"
      ]
    },
    "message": {
      "description": "Message describing the purpose of the commit",
      "example": "Fix #42",
      "type": "string"
    },
    "tree": {
      "type": "object",
      "properties": {
        "sha": {
          "description": "SHA for the commit",
          "example": "7638417db6d59f3c431d3e1f261cc637155684cd",
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      },
      "required": [
        "sha",
        "url"
      ]
    },
    "parents": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "sha": {
            "description": "SHA for the commit",
            "example": "7638417db6d59f3c431d3e1f261cc637155684cd",
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "html_url": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "sha",
          "url",
          "html_url"
        ]
      }
    },
    "verification": {
      "type": "object",
      "properties": {
        "verified": {
          "type": "boolean"
        },
        "reason": {
          "type": "string"
        },
        "signature": {
          "type": "string",
          "nullable": true
        },
        "payload": {
          "type": "string",
          "nullable": true
        },
        "verified_at": {
          "type": "string",
          "nullable": true
        }
      },
      "required": [
        "verified",
        "reason",
        "signature",
        "payload",
        "verified_at"
      ]
    },
    "html_url": {
      "type": "string",
      "format": "uri"
    }
  },
  "required": [
    "sha",
    "node_id",
    "url",
    "html_url",
    "author",
    "committer",
    "tree",
    "message",
    "parents",
    "verification"
  ]
}

Usage

from ocp_agent import OCPAgent

agent = OCPAgent()
await agent.register_api('github')

# Call this tool
result = await agent.call_tool('gitCreateCommit', {
    # Add required parameters here
})