Skip to main content
Glama

push_files_content

Push multiple files with direct content to a GitHub repository in a single commit, enabling batch file updates without local file management.

Instructions

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

Input Schema

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

Implementation Reference

  • Core handler function that implements the logic to push multiple files' content to GitHub repo 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); }
  • Zod input schema defining parameters for the push_files_content tool: owner, repo, branch, files array, and commit message.
    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 tools list, specifying name, description, and schema.
    { name: "push_files_content", description: "Push multiple files with direct content to a GitHub repository in a single commit", inputSchema: zodToJsonSchema(files.PushFilesContentSchema), },
  • MCP request handler case for push_files_content: parses arguments, calls the implementation function, and formats response.
    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) }], }; }

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