Skip to main content
Glama

push_files_from_path

Push multiple files from specified filesystem paths to a GitHub repository in a single commit, streamlining file updates and version control.

Instructions

Push multiple files from filesystem paths 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 from filesystem paths
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 from filesystem paths", "items": { "additionalProperties": false, "properties": { "filepath": { "type": "string" }, "path": { "type": "string" } }, "required": [ "path", "filepath" ], "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

  • The core handler function that reads multiple files from local filesystem paths, validates their existence, converts them to content, and pushes them to a GitHub repository using pushFilesContent.
    export async function pushFilesFromPath( owner: string, repo: string, branch: string, files: FilePath[], message: string ) { try { // First verify all files exist before attempting any operations await Promise.all( files.map(async (file) => { try { await fs.access(file.filepath); } catch (err) { const error = err as Error; throw new Error(`File not accessible: ${file.filepath} - ${error.toString()}`); } }) ); // Convert FilePath objects to FileContent objects by reading the files const fileContents: FileContent[] = await Promise.all( files.map(async (file) => { try { const content = await fs.readFile(file.filepath, 'utf8'); return { path: file.path, content, }; } catch (err) { const error = err as Error; throw new Error(`Failed to read file ${file.filepath}: ${error.toString()}`); } }) ); if (!fileContents.length) { throw new Error('No files were successfully read'); } // Use the existing pushFilesContent function with the read content return pushFilesContent(owner, repo, branch, fileContents, message); } catch (err) { const error = err as Error; throw new Error(`Failed to push files: ${error.toString()}`); } }
  • Zod schema defining the input parameters for the push_files_from_path tool, including repo details, branch, local file paths, and commit message.
    export const PushFilesFromPathSchema = 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(FilePathSchema).describe("Array of files to push from filesystem paths"), message: z.string().describe("Commit message"), });
  • index.ts:93-97 (registration)
    Tool registration in the listTools response, specifying name, description, and input schema.
    { name: "push_files_from_path", description: "Push multiple files from filesystem paths to a GitHub repository in a single commit", inputSchema: zodToJsonSchema(files.PushFilesFromPathSchema), },
  • index.ts:253-265 (registration)
    Dispatch handler in the main switch statement that parses arguments and calls the pushFilesFromPath function.
    case "push_files_from_path": { const args = files.PushFilesFromPathSchema.parse(request.params.arguments); const result = await files.pushFilesFromPath( args.owner, args.repo, args.branch, args.files, args.message ); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
  • Supporting schema for individual file mapping from local filepath to repo path, used in PushFilesFromPathSchema.
    export const FilePathSchema = z.object({ path: z.string(), filepath: z.string(), });

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