API Documentation
Everything you need to integrate Code Context into your AI workflow.
Overview
Code Context provides semantic code search for AI coding assistants. Index any GitHub repository and search code by meaning, not just keywords.
Base URL
Features
- Semantic Search - Find code by meaning using embeddings
- Fast Indexing - Index repositories in seconds
- MCP Support - Native Model Context Protocol integration
- REST API - Simple HTTP endpoints for any integration
Authentication
All API endpoints require authentication via API key. Pass your key in one of these headers:
# Option 1: X-API-Key header X-API-Key: ghctx_your_api_key_here # Option 2: Authorization header Authorization: Bearer ghctx_your_api_key_here
Generate an API key from your dashboard.
Quick Start
Get started in 3 steps:
1. Get an API Key
Sign in with GitHub and generate an API key from the dashboard.
2. Index a Repository
curl -X POST https://synsc-code-context.onrender.com/api/v1/repositories/index \
-H "X-API-Key: ghctx_your_key" \
-H "Content-Type: application/json" \
-d '{"url": "facebook/react"}'3. Search Code
curl -X POST https://synsc-code-context.onrender.com/api/v1/search \
-H "X-API-Key: ghctx_your_key" \
-H "Content-Type: application/json" \
-d '{"query": "useState hook implementation"}'Index Repository
Clone and index a GitHub repository for semantic search.
REQUEST BODY
| Parameter | Type | Description |
|---|---|---|
| url* | string | Repository URL or shorthand (e.g., "facebook/react") |
| branch | string | Branch to index (default: "main") |
RESPONSE
{
"success": true,
"status": "indexed",
"repo_id": "abc-123-def",
"owner": "facebook",
"name": "react",
"branch": "main",
"files_indexed": 2847,
"chunks_created": 12453,
"indexing_time_ms": 12400
}Search Code
Search code using natural language. Returns semantically relevant code snippets.
REQUEST BODY
| Parameter | Type | Description |
|---|---|---|
| query* | string | Natural language search query |
| repo_ids | string[] | Limit search to specific repositories |
| language | string | Filter by programming language |
| top_k | integer | Number of results (default: 10, max: 100) |
RESPONSE
{
"success": true,
"query": "useState hook implementation",
"results": [
{
"repo_id": "abc-123",
"repo_name": "facebook/react",
"file_path": "packages/react/src/ReactHooks.js",
"content": "function useState(initialState) {...}",
"start_line": 45,
"end_line": 67,
"language": "javascript",
"relevance_score": 0.92
}
],
"count": 10,
"search_time_ms": 134
}List Repositories
List all indexed repositories.
QUERY PARAMETERS
| Parameter | Type | Description |
|---|---|---|
| limit | integer | Max results (default: 50) |
| offset | integer | Pagination offset |
Get Repository
Get detailed information about an indexed repository.
Delete Repository
Remove a repository from the index. This action cannot be undone.
Get File
Get file content from an indexed repository.
REQUEST BODY
| Parameter | Type | Description |
|---|---|---|
| repo_id* | string | Repository ID |
| file_path* | string | Path to file (e.g., "src/main.py") |
| start_line | integer | Start line (1-indexed) |
| end_line | integer | End line |
MCP Integration
Code Context supports the Model Context Protocol (MCP) for direct integration with AI assistants like Cursor.
Cursor Configuration
Add to your ~/.cursor/mcp.json:
{
"mcpServers": {
"synsc-code-context": {
"url": "https://synsc-code-context.onrender.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY_HERE"
}
}
}
}
Replace YOUR_API_KEY_HERE with your API key from the dashboard.
Available Tools
Once connected, your AI assistant can use these tools:
index_repository(url, branch)- Index a GitHub repositorysearch_code(query, ...)- Semantic code searchlist_repositories()- List your indexed reposget_repository(repo_id)- Get repo detailsdelete_repository(repo_id)- Remove a repo from your collectionget_file(repo_id, file_path)- Get file contentanalyze_repository(repo_id)- Deep codebase analysisget_directory_structure(repo_id)- Get file treesearch_symbols(name, ...)- Find functions, classes, methodsget_symbol(symbol_id)- Get symbol details