gitingest/examples/start_mcp_server.py
Iwan Burel 3b40cd6836 feat: add MCP (Model Context Protocol) server support
- Add MCP server implementation with stdio transport
- Integrate MCP server option in CLI with --mcp-server flag
- Add ingest_repository tool for MCP clients
- Remove HTTP transport, keeping only stdio for simplicity
- Add MCP dependencies and optional installation group
- Include comprehensive documentation and client examples
- Support GitHub token authentication through MCP

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-12 00:41:07 +02:00

46 lines
No EOL
1.2 KiB
Python

#!/usr/bin/env python3
"""
Startup script for the Gitingest MCP server.
This script starts the MCP server with stdio transport.
Usage:
python examples/start_mcp_server.py
"""
import sys
import asyncio
from pathlib import Path
# Add the src directory to the Python path
src_path = Path(__file__).parent.parent / "src"
sys.path.insert(0, str(src_path))
from gitingest.mcp_server import start_mcp_server
async def main_wrapper():
"""Start the MCP server with stdio transport."""
print("Starting Gitingest MCP Server")
print(" Transport: stdio")
print(" Mode: stdio (for MCP clients that support stdio transport)")
print("\nServer Configuration:")
print(" - Repository analysis and text digest generation")
print(" - Token counting and file structure analysis")
print(" - Support for both local directories and Git repositories")
print()
try:
await start_mcp_server()
except KeyboardInterrupt:
print("\nServer stopped by user")
except Exception as e:
print(f"\nError starting server: {e}")
import traceback
traceback.print_exc()
sys.exit(1)
if __name__ == "__main__":
asyncio.run(main_wrapper())