Skip to main content
Experimental API - Context Engine SDK is experimental and subject to breaking changes.

Available Examples


Getting the Examples

All example code is available in the Auggie repository. To access the examples:
git clone https://github.com/augmentcode/auggie.git
cd auggie/examples/typescript-sdk/context
Each example is a complete, runnable application demonstrating different use cases of the Auggie SDK.

Prerequisites

Before running the examples:
  1. Runtime - One of the following:
    • TypeScript: Node.js 18+
    • Python: Python 3.10+
  2. Auggie CLI - Required for FileSystem Context examples
    npm install -g @augmentcode/auggie@prerelease
    
  3. Authentication - Required for all examples
    auggie login
    
    This creates a session file at ~/.augment/session.json with your API token. Alternatively, set environment variables:
    export AUGMENT_API_TOKEN="your-api-token"
    export AUGMENT_API_URL="https://your-tenant.api.augmentcode.com"
    

Setup

Install dependencies:
cd examples/typescript-sdk/context
npm install

Simple Examples

Get started quickly with these basic examples that demonstrate core SDK functionality.

Direct Context

Demonstrates indexing files from any source and performing semantic searches with AI-powered question answering. Quick Start:
npm run direct-context
Or run directly:
npx tsx direct-context/index.ts

FileSystem Context

Shows how to search a local directory using automatic file discovery via the MCP protocol. Prerequisites:
  • Auggie CLI must be installed and in your PATH
  • Authentication via auggie login or AUGMENT_API_TOKEN environment variable
  • A .gitignore or .augmentignore file in the workspace directory to exclude node_modules/ and other large directories
Important: The FileSystem Context indexes all files in the workspace directory. To avoid timeouts when indexing large directories (like node_modules/), make sure you have a .gitignore or .augmentignore file that excludes them. Quick Start:
npm run filesystem-context
Or run directly:
npx tsx filesystem-context/index.ts

Developer Tools

Build production-ready applications with these server examples.

File Search Server

A REST API server that provides semantic file search with AI-powered summarization. Prerequisites: Auggie CLI must be installed and in your PATH. Quick Start:
npm run file-search-server [workspace-directory]
Then query the API:
curl "http://localhost:3000/search?q=typescript"
Or run directly:
npx tsx file-search-server/index.ts .

Prompt Enhancer Server

An HTTP server that automatically enriches user prompts with relevant codebase context. Prerequisites: Auggie CLI must be installed and in your PATH. Quick Start:
npm run prompt-enhancer-server [workspace-directory]
Then enhance prompts:
curl -X POST http://localhost:3001/enhance \
  -H "Content-Type: application/json" \
  -d '{"prompt": "fix the login bug"}'
Or run directly:
npx tsx prompt-enhancer-server/index.ts .

CI/CD Integration

Integrate the SDK into your continuous integration workflows.

GitHub Action Indexer

Automatically index your GitHub repositories with zero-question setup and incremental updates. Perfect for CI/CD workflows and keeping your codebase searchable. Key Features:
  • πŸ”„ Incremental indexing - Only processes changed files for efficiency
  • πŸ’Ύ Smart caching - Persists index state between runs
  • πŸš€ 30-second setup - From zero to running GitHub Action
Installation:
# Install directly into your repository
cd /path/to/your/repository
npx @augment-samples/github-action-indexer install

# Add your API secrets to GitHub repository settings
# Push to trigger automatic indexing on every commit
What It Does:
  1. Indexes your codebase automatically on every push
  2. Updates incrementally using GitHub’s Compare API
  3. Caches index state for fast subsequent runs
  4. Handles large repositories with optimized performance settings
Perfect For:
  • Keeping your codebase searchable and up-to-date
  • CI/CD workflows that need codebase understanding
  • Teams wanting automatic repository indexing
  • Projects with frequent commits (incremental updates are fast)
Try It Locally First:
cd github-action-indexer
npm install
export AUGMENT_API_TOKEN="your-token"
export AUGMENT_API_URL="https://your-tenant.api.augmentcode.com/"
export GITHUB_TOKEN="your-github-token"
export GITHUB_REPOSITORY="owner/repo"
export GITHUB_SHA="$(git rev-parse HEAD)"
npm run index
npm run search "authentication functions"
πŸ“– Complete Setup Guides:

Troubleshooting

MCP Timeout in FileSystem Context

Problem: The FileSystem Context example times out during indexing. Cause: The workspace directory contains too many files (e.g., node_modules/ with 45,000+ files). Solution: Create a .gitignore or .augmentignore file in the workspace directory to exclude large directories:
# .gitignore or .augmentignore
node_modules/
dist/
__pycache__/
.venv/
*.log
.DS_Store
The auggie CLI respects both .gitignore and .augmentignore patterns and will skip excluded files during indexing.

Authentication Errors

Problem: Error: API key is required for searchAndAsk() or ValueError: API credentials are required Cause: The SDK cannot find your authentication credentials. Solution: Run auggie login to authenticate, or set the AUGMENT_API_TOKEN and AUGMENT_API_URL environment variables.

Next Steps