-
Notifications
You must be signed in to change notification settings - Fork 268
Add MCP server implementation for RenderGit\n\n- Added MCP server tha... #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
demo_mcp.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
rendergit_package/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # rendergit_package/__init__.py |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.