Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Virtual environments
venv/
.env

# IDEs
.vscode/
.idea/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db
58 changes: 58 additions & 0 deletions MCP_SERVER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# RenderGit MCP Server

This directory contains an MCP (Model Context Protocol) server implementation for RenderGit that allows you to flatten GitHub repositories into text format for LLM context.

## Installation

1. Create a virtual environment:
```bash
python3 -m venv venv
source venv/bin/activate
```

2. Install the package:
```bash
pip install -e .
```

## Running the MCP Server

To start the MCP server, run:
```bash
rendergit-mcp
```

This will start the server and listen for MCP connections.

## Using with Claude Desktop

1. First, ensure you have [Claude Desktop](https://claude.ai/download) installed
2. Configure Claude Desktop to use the RenderGit MCP server by adding the following to your Claude configuration:

```json
{
"mcpServers": {
"rendergit": {
"command": "rendergit-mcp"
}
}
}
```

3. Restart Claude Desktop
4. In any conversation with Claude, you can now use the RenderGit tool to flatten repositories

## Using the MCP Tool

Once connected, you can ask Claude to flatten a repository:

> "Please flatten the code in https://github.com/karpathy/nanoGPT for me to analyze"

Claude will use the MCP tool to clone the repository, flatten it into CXML format, and provide it for analysis.

## Testing the MCP Server

You can test the MCP server with the provided test script:
```bash
python test_mcp_server.py
```
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ Once open, you can toggle between two views:

There's a few other smaller options, see the code.

## MCP Server

RenderGit also includes an MCP (Model Context Protocol) server that allows you to flatten GitHub repositories and feed them directly into LLMs through compatible tools like Claude Desktop.

See [MCP_SERVER.md](MCP_SERVER.md) for detailed instructions on setting up and using the MCP server.

## Features

- **Dual view modes** - toggle between Human and LLM views
Expand All @@ -45,6 +51,7 @@ There's a few other smaller options, see the code.
- **Sidebar navigation** with file links and sizes
- **Responsive design** that works on mobile
- **Search-friendly** - use Ctrl+F to find anything across all files
- **MCP Server** - integrate directly with Claude Desktop and other MCP-compatible tools

## Contributing

Expand Down
62 changes: 62 additions & 0 deletions demo_mcp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3
"""
Example script demonstrating how to use the RenderGit MCP server programmatically
"""

import asyncio
import json
import subprocess
import sys
import time

async def demonstrate_mcp_usage():
"""Demonstrate how to use the RenderGit MCP server"""
print("Demonstrating RenderGit MCP server usage...")

# Start the MCP server as a subprocess
server_process = subprocess.Popen(
[sys.executable, "-m", "rendergit_package.mcp_server"],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
bufsize=0
)

# Give the server a moment to start
time.sleep(2)

# Check if the process is still running
if server_process.poll() is not None:
stderr = server_process.stderr.read()
print(f"Server failed to start: {stderr}")
return

print("✓ MCP server started successfully")
print("\nYou can now use this server with any MCP-compatible client, such as:")
print("- Claude Desktop")
print("- Other MCP tools that support the Model Context Protocol")
print("\nTo use with Claude Desktop, add this to your configuration:")
print("""

{
"mcpServers": {
"rendergit": {
"command": "rendergit-mcp"
}
}
}

""")

# Terminate the server
server_process.terminate()
try:
server_process.wait(timeout=5)
except subprocess.TimeoutExpired:
server_process.kill()

print("✓ MCP server demonstration completed")

if __name__ == "__main__":
asyncio.run(demonstrate_mcp_usage())
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ requires-python = ">=3.10"
dependencies = [
"markdown>=3.8.2",
"pygments>=2.19.2",
"mcp>=1.0.0",
]
classifiers = [
"Development Status :: 4 - Beta",
Expand All @@ -27,7 +28,8 @@ classifiers = [
]

[project.scripts]
rendergit = "rendergit:main"
rendergit = "rendergit_package.rendergit:main"
rendergit-mcp = "rendergit_package.mcp_server:main"

[project.urls]
Homepage = "https://github.com/karpathy/rendergit"
Expand Down
1 change: 1 addition & 0 deletions rendergit_package/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# rendergit_package/__init__.py
Loading