This repository documents key lessons learned while working with GitHub's API through Claude MCP (Model Control Protocol). These insights were gathered through practical experience with file operations and error handling.
- API error messages don't always indicate operation failure
- Operations may succeed despite error responses
- Always verify changes directly in the repository
- Don't rely solely on API response messages for status
- Each file version has a unique SHA identifier
- Current SHA is required for file updates
- Successful updates generate new SHAs
- Using outdated SHAs results in "Conflict" errors
- Always get latest SHA before attempting updates
- Content can be sent as plain text with UTF-8 encoding
- Base64 encoding is also supported
- Be careful with JSON structures - they will be literally written to the file
- API expects specific parameters like
content.encodingandcontent.content - Proper encoding declaration is essential
- Get latest file info before updates
- Track new SHAs after successful updates
- Verify changes in the repository
- Test with small changes first
- Keep track of the operation's actual effects
- Document unexpected behaviors
sha: Current file's SHA (required for updates)path: File path in the repositorycontent: New content to be writtenmessage: Commit messagebranch: Target branch (usually 'main')encoding: Content encoding type (e.g., 'utf-8', 'base64')
A typical file update process might look like this:
- Get current file info to obtain SHA
- Prepare new content with proper encoding
- Submit update with current SHA
- Verify changes in repository
- Note new SHA for future operations
Even if you get error messages like Invalid arguments: content.encoding: Required or GitHub API error: Conflict, check the repository as the operation may have succeeded.
This documentation was created through interactions with Claude AI, documenting real experiences with GitHub's API integration.