Skip to main content
Glama

push_files_content

Push multiple files with their content to a GitHub repository in a single commit, specifying owner, repo, branch, and commit message for streamlined file updates.

Instructions

Push multiple files with direct content to a GitHub repository in a single commit

Input Schema

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

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "branch": { "description": "Branch to push to (e.g., 'main' or 'master')", "type": "string" }, "files": { "description": "Array of files to push with their content", "items": { "additionalProperties": false, "properties": { "content": { "type": "string" }, "path": { "type": "string" } }, "required": [ "path", "content" ], "type": "object" }, "type": "array" }, "message": { "description": "Commit message", "type": "string" }, "owner": { "description": "Repository owner (username or organization)", "type": "string" }, "repo": { "description": "Repository name", "type": "string" } }, "required": [ "owner", "repo", "branch", "files", "message" ], "type": "object" }

Implementation Reference

  • Handler for the 'push_files_content' tool call in the MCP server, which parses input arguments using the schema and invokes the core pushFilesContent function from files module.
    case "push_files_content": { const args = files.PushFilesContentSchema.parse(request.params.arguments); const result = await files.pushFilesContent( args.owner, args.repo, args.branch, args.files, args.message ); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
  • Zod schema defining the input parameters for the push_files_content tool.
    export const PushFilesContentSchema = 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(FileContentSchema).describe("Array of files to push with their content"), message: z.string().describe("Commit message"), });
  • index.ts:88-92 (registration)
    Registration of the 'push_files_content' tool in the MCP server's list of available tools, including name, description, and input schema reference.
    { name: "push_files_content", description: "Push multiple files with direct content to a GitHub repository in a single commit", inputSchema: zodToJsonSchema(files.PushFilesContentSchema), },
  • Core helper function that implements the logic to push multiple files to GitHub by creating a Git tree, commit, and updating the branch reference.
    export async function pushFilesContent( owner: string, repo: string, branch: string, files: FileContent[], message: string ) { const refResponse = await githubRequest( `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(owner, repo, files, commitSha); const commit = await createCommit(owner, repo, message, tree.sha, [commitSha]); return await updateReference(owner, repo, `heads/${branch}`, commit.sha); }

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/PhialsBasement/mcp-github-server-plus'

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