Skip to main content
Glama

push_files

Commit multiple files to a GitHub repository in one action using push_files. Specify the owner, repo, branch, files, and message to streamline file updates efficiently.

Instructions

Push multiple files to a GitHub repository in a single commit

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchYesBranch to push to (e.g., 'main' or 'master')
filesYesArray of files to push
messageYesCommit message
ownerYesRepository owner (username or organization)
repoYesRepository name

Implementation Reference

  • Core handler function that implements the push_files tool: gets current branch ref, creates a new tree with the files (base64 encoded), creates a new commit, and updates the branch ref.
    export async function pushFiles( github_pat: string, owner: string, repo: string, branch: string, files: FileOperation[], message: string ) { const refResponse = await githubRequest( github_pat, `https://api.github.com/repos/${owner}/${repo}/git/refs/heads/${branch}` ); const ref = GitHubReferenceSchema.parse(refResponse); const commitSha = ref.object.sha; const tree = await createTree(github_pat, owner, repo, files, commitSha); const commit = await createCommit(github_pat, owner, repo, message, tree.sha, [commitSha]); return await updateReference(github_pat, owner, repo, `heads/${branch}`, commit.sha); }
  • Main input schema for push_files tool, used in tool registration.
    export const PushFilesSchema = z.object({ owner: z.string().describe("Repository owner (username or organization)"), repo: z.string().describe("Repository name"), branch: z.string().describe("Branch to push to (e.g., 'main' or 'master')"), files: z.array(FileOperationSchema).describe("Array of files to push"), message: z.string().describe("Commit message"), });
  • Extended schema including github_pat, used for parsing arguments in the handler.
    export const _PushFilesSchema = PushFilesSchema.extend({ github_pat: z.string().describe("GitHub Personal Access Token"), });
  • Schema for individual file operations, used in files array of PushFilesSchema.
    export const FileOperationSchema = z.object({ path: z.string(), content: z.string(), });
  • src/index.ts:98-102 (registration)
    Tool registration in the listTools handler, defining the tool's metadata and input schema.
    { name: "push_files", description: "Push multiple files to a GitHub repository in a single commit", inputSchema: zodToJsonSchema(files.PushFilesSchema), },
  • src/index.ts:422-435 (registration)
    Dispatch handler in callToolRequest switch that validates args with _PushFilesSchema and invokes the pushFiles implementation.
    case "push_files": { const args = files._PushFilesSchema.parse(params.arguments); const result = await files.pushFiles( args.github_pat, args.owner, args.repo, args.branch, args.files, args.message ); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MissionSquad/mcp-github'

If you have feedback or need assistance with the MCP directory API, please join our Discord server