MCPcopy Index your code
hub / github.com/PankajKumardev/claude-code-clone

github.com/PankajKumardev/claude-code-clone @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
56 symbols 110 edges 10 files 3 documented · 5%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Claude Code Assistant

An AI-driven coding companion powered by Gemini, LangGraph, and MCP — built for developers who want an intelligent, context-aware terminal assistant.

🎯 Features

  • AI-Powered Assistance: Leverages Gemini API (Gemini 2.5 Flash) for intelligent code understanding and generation
  • Tool Integration: Connects to external tools via Model Context Protocol (MCP)
  • Filesystem operations (read, write, search files)
  • GitHub integration (with token support)
  • Web search via Tavily API (1,000 free searches/month, no credit card!)
  • Conversation Memory: Maintains context across interactions with PostgreSQL database
  • Clean CLI Interface: Professional copper-themed command-line interface
  • State Management: LangGraph-powered agent workflow for complex task orchestration

📋 Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • Gemini API key
  • (Optional) GitHub token for GitHub integration
  • (Optional) Tavily API key for web search (free, no credit card)

🚀 Installation

  1. Clone the repository
git clone <repository-url>
cd claude-code
  1. Install dependencies
npm install
  1. Set up environment variables

Create a .env file in the root directory:

# Database
DATABASE_URL="postgresql://user:password@localhost:5432/claude_code"

# Gemini API
GEMINI_API_KEY="your_gemini_api_key_here"

# Optional: GitHub Integration
GITHUB_TOKEN="your_github_token_here"

# Optional: Tavily Search API (Free 1000 searches/month, no CC!)
# Get your free key at: https://tavily.com
TAVILY_API_KEY="your_tavily_api_key_here"
  1. Set up the database
npm run db:migrate
  1. Build the project
npm run build

🎮 Usage

Start the assistant

npm start

Available Commands

Once the assistant is running:

  • /help - Show available commands
  • /tools - List all connected tools
  • /exit - Exit the application

Example Interactions

You: read the files in this project and summarize it

You: create a new file called test.js with a hello world function

You: search for TODO comments in all files

🏗️ Architecture

Project Structure

claude-code/
├── src/
│   ├── agent/           # LangGraph state machine
│   │   ├── graph.ts     # State graph definition
│   │   ├── nodes.ts     # Node implementations
│   │   └── state.ts     # State schema
│   ├── services/        # Business logic services
│   │   ├── gemini.service.ts      # Gemini API integration
│   │   ├── mcp.service.ts         # MCP server management
│   │   └── conversation.service.ts # Database operations
│   ├── cli/             # Command-line interface
│   │   └── interface.ts
│   ├── db/              # Database setup
│   │   └── prisma.ts
│   └── index.ts         # Application entry point
├── prisma/
│   └── schema.prisma    # Database schema
└── package.json

System Flow

  1. User Input → CLI Interface
  2. LangGraph State Machine:
  3. User Input Node: Saves message to database
  4. Model Node: Claude decides to respond or use tools
  5. Tool Node: Executes MCP tools, loops back if needed
  6. Database → Stores conversations, messages, and tool executions
  7. Response → Displayed to user

Database Schema

  • Conversation: Stores conversation metadata
  • Message: Individual messages (user, assistant, tool)
  • ToolExecution: Logs of tool calls with input/output
  • StateCheckpoint: State snapshots for debugging

🛠️ Development

Scripts

npm run dev        # Run in development mode with auto-reload
npm run build      # Compile TypeScript to JavaScript
npm start          # Run the compiled application
npm run db:migrate # Run database migrations
npm run db:studio  # Open Prisma Studio (database GUI)

MCP Servers

The assistant connects to the following MCP servers:

  • @modelcontextprotocol/server-filesystem: File operations
  • @missionsquad/mcp-github: GitHub integration (optional, requires token)
  • @tavily/tavily-mcp-server: AI-powered web search (optional, 1000 free searches/month)

Servers are automatically installed via npx when the application starts.

🎨 Features

Copper Theme

The CLI uses a consistent copper color scheme (#CD6F47) for a professional appearance:

  • ASCII art banner
  • Success indicators
  • Status messages
  • Tool execution feedback

Conversation Context

  • Automatically loads last 10 messages for context
  • Prevents token overflow with message limiting
  • Persistent storage in PostgreSQL

Error Handling

  • Silent error handling for clean user experience
  • Graceful shutdown on SIGINT/SIGTERM
  • EPIPE error suppression for MCP transport

📝 Configuration

Adjusting Context Window

Edit src/index.ts to change the number of messages loaded:

const conversationHistory = await conversationService.getConversationMessages(
  conversation.id,
  10 // Change this number
);

Adding New MCP Servers

Edit src/index.ts to add new MCP server connections:

await mcpService.connectServer('server-name', 'npx', [
  '-y',
  'package-name',
  ...args,
]);

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

[Your License Here]

🙏 Acknowledgments

  • Gemini API by Google
  • LangGraph.js for agent orchestration
  • Model Context Protocol for tool integration
  • Prisma for database management

Extension points exported contracts — how you extend this code

MCPServer (Interface)
(no doc)
src/services/mcp.service.ts

Core symbols most depended-on inside this repo

saveMessages
called by 4
src/services/conversation.service.ts
disconnectAll
called by 3
src/services/mcp.service.ts
isAvailable
called by 3
src/services/web-search.service.ts
stopThinking
called by 2
src/cli/interface.ts
displayResponse
called by 2
src/cli/interface.ts
displayError
called by 2
src/cli/interface.ts
connectServer
called by 2
src/services/mcp.service.ts
getAllTools
called by 2
src/services/mcp.service.ts

Shape

Method 39
Class 10
Function 6
Interface 1

Languages

TypeScript100%

Modules by API surface

src/cli/interface.ts15 symbols
src/services/mcp.service.ts12 symbols
src/services/conversation.service.ts9 symbols
src/services/web-search.service.ts7 symbols
src/services/gemini.service.ts7 symbols
src/agent/nodes.ts3 symbols
src/index.ts2 symbols
src/agent/graph.ts1 symbols

Datastores touched

claude_codeDatabase · 1 repos

For agents

$ claude mcp add claude-code-clone \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page