|
| 1 | +# Gitingest MCP Server |
| 2 | + |
| 3 | +Gitingest includes an MCP (Model Context Protocol) server that allows LLMs to directly access repository analysis capabilities through the MCP protocol. |
| 4 | + |
| 5 | +## What is MCP? |
| 6 | + |
| 7 | +The Model Context Protocol (MCP) is a standardized protocol that enables language models to interact with external tools and resources in a structured manner. It facilitates the integration of specialized capabilities into LLM workflows. |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +To use the MCP server, install Gitingest with MCP dependencies: |
| 12 | + |
| 13 | +```bash |
| 14 | +pip install gitingest[mcp] |
| 15 | +``` |
| 16 | + |
| 17 | +## Starting the MCP Server |
| 18 | + |
| 19 | +### Stdio Transport (Default) |
| 20 | + |
| 21 | +```bash |
| 22 | +gitingest --mcp-server |
| 23 | +``` |
| 24 | + |
| 25 | +The MCP server uses stdio for communication by default, making it compatible with all MCP clients. |
| 26 | + |
| 27 | + |
| 28 | +## Available Tools |
| 29 | + |
| 30 | +### `ingest_repository` |
| 31 | + |
| 32 | +Ingests a Git repository or local directory and returns a structured digest. |
| 33 | + |
| 34 | +**Parameters:** |
| 35 | +- `source` (required): Git repository URL or local directory path |
| 36 | +- `max_file_size` (optional): Maximum file size in bytes (default: 10485760) |
| 37 | +- `include_patterns` (optional): Shell patterns to include files |
| 38 | +- `exclude_patterns` (optional): Shell patterns to exclude files |
| 39 | +- `branch` (optional): Git branch to clone and ingest |
| 40 | +- `include_gitignored` (optional): Include files ignored by .gitignore (default: false) |
| 41 | +- `include_submodules` (optional): Include Git submodules (default: false) |
| 42 | +- `token` (optional): GitHub personal access token for private repositories |
| 43 | + |
| 44 | +**Usage example:** |
| 45 | +```json |
| 46 | +{ |
| 47 | + "source": "https://github.com/coderamp-labs/gitingest", |
| 48 | + "max_file_size": 1048576, |
| 49 | + "include_patterns": ["*.py", "*.md"], |
| 50 | + "exclude_patterns": ["tests/*"] |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +## MCP Client Configuration |
| 55 | + |
| 56 | +### Stdio Transport Configuration |
| 57 | + |
| 58 | +Create a configuration file for your MCP client: |
| 59 | + |
| 60 | +```json |
| 61 | +{ |
| 62 | + "mcpServers": { |
| 63 | + "gitingest": { |
| 64 | + "command": "gitingest", |
| 65 | + "args": ["--mcp-server"], |
| 66 | + "env": { |
| 67 | + "GITHUB_TOKEN": "${GITHUB_TOKEN}" |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | + |
| 75 | +### Environment Variables |
| 76 | + |
| 77 | +- `GITHUB_TOKEN`: GitHub personal access token for private repositories |
| 78 | + |
| 79 | +## Integration Examples |
| 80 | + |
| 81 | +### Python Client Examples |
| 82 | + |
| 83 | +See the following examples for how to use the Gitingest MCP server: |
| 84 | + |
| 85 | +- **`examples/mcp_client_example.py`** - Stdio transport example |
| 86 | +- **`examples/start_mcp_server.py`** - Startup script for stdio transport |
| 87 | + |
| 88 | +### Integration with Claude Desktop |
| 89 | + |
| 90 | +1. Install Gitingest with MCP dependencies |
| 91 | +2. Create an MCP configuration file in your Claude configuration directory |
| 92 | +3. Restart Claude Desktop |
| 93 | +4. Use Gitingest tools in your conversations |
| 94 | + |
| 95 | +### Integration with Other MCP Clients |
| 96 | + |
| 97 | +The Gitingest MCP server is compatible with all MCP-compliant clients. Consult your MCP client's documentation for specific integration instructions. |
| 98 | + |
| 99 | +## Output Format |
| 100 | + |
| 101 | +The MCP server returns structured content that includes: |
| 102 | + |
| 103 | +1. **Summary**: General information about the repository |
| 104 | +2. **File Structure**: Tree structure of files and directories |
| 105 | +3. **Content**: Code file content with LLM-optimized formatting |
| 106 | + |
| 107 | +## Error Handling |
| 108 | + |
| 109 | +The MCP server handles errors gracefully and returns informative error messages. Common errors include: |
| 110 | + |
| 111 | +- Private repositories without authentication token |
| 112 | +- Invalid repository URLs |
| 113 | +- Network issues during cloning |
| 114 | +- Files that are too large |
| 115 | + |
| 116 | +## Limitations |
| 117 | + |
| 118 | +- The MCP server does not maintain a cache of ingested repositories (future feature) |
| 119 | +- Persistent resources are not yet implemented |
| 120 | +- The server uses stdio transport for MCP communication |
| 121 | + |
| 122 | +## Development |
| 123 | + |
| 124 | +To contribute to the MCP server: |
| 125 | + |
| 126 | +1. Consult the MCP specification: https://modelcontextprotocol.io/ |
| 127 | +2. Tests are located in `tests/test_mcp_server.py` |
| 128 | +3. The client example is located in `examples/mcp_client_example.py` |
| 129 | + |
| 130 | +## Support |
| 131 | + |
| 132 | +For help with the MCP server: |
| 133 | + |
| 134 | +- Consult the official MCP documentation |
| 135 | +- Open an issue on GitHub |
| 136 | +- Join the Discord community |
0 commit comments