Get Started

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

https://synsc-code-context.onrender.com

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

POST /api/v1/repositories/index

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

POST /api/v1/search

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

GET /api/v1/repositories

List all indexed repositories.

QUERY PARAMETERS

ParameterTypeDescription
limit integer Max results (default: 50)
offset integer Pagination offset

Get Repository

GET /api/v1/repositories/{repo_id}

Get detailed information about an indexed repository.

Delete Repository

DELETE /api/v1/repositories/{repo_id}

Remove a repository from the index. This action cannot be undone.

Get File

POST /api/v1/files/get

Get file content from an indexed repository.

REQUEST BODY

ParameterTypeDescription
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 repository
  • search_code(query, ...) - Semantic code search
  • list_repositories() - List your indexed repos
  • get_repository(repo_id) - Get repo details
  • delete_repository(repo_id) - Remove a repo from your collection
  • get_file(repo_id, file_path) - Get file content
  • analyze_repository(repo_id) - Deep codebase analysis
  • get_directory_structure(repo_id) - Get file tree
  • search_symbols(name, ...) - Find functions, classes, methods
  • get_symbol(symbol_id) - Get symbol details