# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Project Overview
This is a Model Context Protocol (MCP) server that provides seamless interaction with CodeGPT's Code Graphs. The server enables semantic code search, dependency analysis, and code retrieval across repository knowledge graphs.
## Development Commands
```bash
# Build the project
npm run build
# Build and watch for changes during development
npm run watch
# Test the MCP server locally
node dist/index.js
# Debug MCP server with wrapper
node debug-mcp.js
```
## Architecture
### Core Components
- **src/index.ts**: Main MCP server implementation with all tool definitions
- **debug-mcp.js**: Wrapper script for debugging ES module compatibility
- **dist/**: Compiled JavaScript output (generated by TypeScript)
### MCP Tools Implemented
The server implements 6 main tools for interacting with CodeGPT's knowledge graphs:
1. **list-graphs**: Lists available repository graphs (only when CODEGPT_GRAPH_ID not set)
2. **get-code**: Retrieves complete code implementation of functionalities
3. **find-direct-connections**: Explores immediate relationships in the code graph
4. **nodes-semantic-search**: Semantic search for code functionalities
5. **docs-semantic-search**: Semantic search through documentation
6. **get-usage-dependency-links**: Deep dependency analysis for impact assessment
### Configuration
The server uses environment variables for configuration:
- `CODEGPT_API_KEY` (required): API key for CodeGPT service
- `CODEGPT_ORG_ID` (optional): Organization ID
- `CODEGPT_GRAPH_ID` (optional): Specific graph ID
Arguments can also be passed via command line in order: API_KEY, ORG_ID, GRAPH_ID.
### Key Implementation Details
- Uses `@modelcontextprotocol/sdk` for MCP protocol implementation
- Implements dynamic schema generation based on environment variables
- Includes extensive error handling and logging
- TypeScript with ES2022 target and NodeNext modules
- Communicates with CodeGPT API at `https://api-mcp.codegpt.co/api/v1`
## Publishing
The package is published to npm as `mcp-code-graph` with binary entry point at `dist/index.js`.