@augmentcode/context-connectors

中文文档
0.1.4发布于 2026/02/11MITTypeScriptES Module近 30 天下载 1864

Modular system for indexing any data source and making it searchable via Augment's context engine

原始使用文档
文档目录40 节
  1. Features
  2. Installation
  3. Quick Start
  4. 1. Index Your Codebase
  5. 2. Search
  6. 3. Interactive Agent
  7. CLI Commands
  8. index - Index a data source
  9. search - Search indexed content
  10. agent - Interactive AI agent
  11. list - List local indexes
  12. delete - Delete a local index
  13. mcp stdio - Start MCP server with stdio transport
  14. mcp http - Start MCP server with HTTP transport
  15. About --search-only
  16. Programmatic Usage
  17. Basic Indexing
  18. Search Client
  19. MCP Server
  20. MCP HTTP Server
  21. Security Considerations
  22. MCP HTTP Server Security
  23. Claude Desktop Integration
  24. Remote MCP Client Integration
  25. Connecting with MCP SDK
  26. Testing with curl
  27. GitHub Actions
  28. GitHub Webhook Integration
  29. Vercel / Next.js App Router
  30. Express
  31. Custom Framework
  32. GitHub App Setup
  33. Environment Variables
  34. Data Storage
  35. Architecture
  36. Filtering
  37. Website Source
  38. Limitations
  39. S3-Compatible Storage
  40. License

Context Connectors

An open-source library built on the Context Engine SDK that makes diverse sources searchable across agents and apps.

Features

  • Multiple Sources: Index code, documentation, runbooks, schemas, and configs from GitHub, GitLab, BitBucket, or websites
  • Flexible Storage: Store indexes locally or in S3 for persistent storage in production apps
  • Multiple Clients: CLI search, interactive agent, MCP server (local & remote)
  • Incremental Updates: Only re-index what changed
  • Smart Filtering: Respects .gitignore, .augmentignore, and filters binary/generated files

Installation

npm install @augmentcode/context-connectors

Install optional dependencies based on your use case:

# For GitHub source
npm install @octokit/rest

# For S3 storage
npm install @aws-sdk/client-s3

# For MCP server (Claude Desktop)
npm install @modelcontextprotocol/sdk

Quick Start

1. Index Your Codebase

# Set required environment variables
export AUGMENT_API_TOKEN='your-token'
export AUGMENT_API_URL='https://your-tenant.api.augmentcode.com/'

# Index a GitHub repository
export GITHUB_TOKEN='your-github-token'
npx context-connectors index github --owner myorg --repo myrepo -i my-project

# Index a BitBucket repository
export BITBUCKET_TOKEN='your-bitbucket-token'
npx context-connectors index bitbucket --workspace myworkspace --repo myrepo -i my-project

# Index a website
npx context-connectors index website --url https://docs.example.com -i my-docs
# Search and get an AI-generated answer (default)
npx context-connectors search "authentication logic" -i my-project

# Get raw search results without AI processing
npx context-connectors search "API routes" -i my-project --raw

3. Interactive Agent

npx context-connectors agent -i my-project --provider openai

CLI Commands

index - Index a data source

context-connectors index <source> [options]
SourceDescription
githubIndex a GitHub repository
gitlabIndex a GitLab project
bitbucketIndex a Bitbucket repository
websiteCrawl and index a website

Common options for all sources:

OptionDescriptionDefault
-i, --index <name>Index name-
--store <type>Store type: filesystem, s3filesystem
--store-path <path>Filesystem store pathPlatform-specific

GitHub-specific options

OptionDescriptionDefault
--owner <owner>Repository owner (required)-
--repo <repo>Repository name (required)-
--ref <ref>Branch, tag, or commitHEAD

GitLab-specific options

OptionDescriptionDefault
--project <id>Project ID or path, e.g., group/project (required)-
--ref <ref>Branch, tag, or commitHEAD
--gitlab-url <url>GitLab base URL (for self-hosted)https://gitlab.com

BitBucket-specific options

OptionDescriptionDefault
--workspace <slug>Workspace slug (required)-
--repo <repo>Repository name (required)-
--ref <ref>Branch, tag, or commitHEAD
--bitbucket-url <url>Bitbucket base URL (for Server/Data Center)https://api.bitbucket.org/2.0

Website-specific options

OptionDescriptionDefault
--url <url>Website URL to crawl (required)-
--max-depth <n>Maximum crawl depth3
--max-pages <n>Maximum pages to crawl100
--include <patterns...>URL patterns to include (glob)-
--exclude <patterns...>URL patterns to exclude (glob)-
--save-content <dir>[Debug] Save crawled content to directory-

search - Search indexed content

context-connectors search <query> [options]
OptionDescriptionDefault
-i, --index <spec>Index spec: name, path:/path, or s3://bucket/key (required)-
--rawReturn raw search results instead of AI-generated answerfalse
--max-chars <n>Max output characters (only with --raw)-

agent - Interactive AI agent

context-connectors agent [query] [options]
OptionDescriptionDefault
-i, --index <specs...>Index spec(s): name, path:/path, or s3://bucket/key (required)-
--provider <name>LLM provider: openai, anthropic, google (required)-
--model <name>Model to useProvider default
--max-steps <n>Max agent steps10
-v, --verboseShow tool callsfalse
--search-onlyDisable list_files/read_file toolsfalse
--printNon-interactive mode: print response and exitfalse

Provider default models:

  • openai: gpt-5-mini
  • anthropic: claude-haiku-4-5
  • google: gemini-3-flash-preview

list - List local indexes

context-connectors list [options]
OptionDescriptionDefault
--store-path <path>Store base path~/.augment/context-connectors

delete - Delete a local index

context-connectors delete <name> [options]
OptionDescriptionDefault
--store-path <path>Store base path~/.augment/context-connectors

mcp stdio - Start MCP server with stdio transport

context-connectors mcp stdio [options]
OptionDescriptionDefault
-i, --index <specs...>Index spec(s): name, path:/path, or s3://bucket/key-
--search-onlyDisable file operationsfalse

mcp http - Start MCP server with HTTP transport

Start an MCP server accessible over HTTP for remote clients.

context-connectors mcp http [options]
OptionDescriptionDefault
-i, --index <specs...>Index spec(s): name, path:/path, or s3://bucket/key-
--port <number>Port to listen on3000
--host <host>Host to bind tolocalhost
--cors <origins>CORS origins (comma-separated or *)-
--base-path <path>Base path for MCP endpoint/mcp
--api-key <key>API key for authentication-
--store <type>Store type: filesystem, s3filesystem
--store-path <path>Store base pathPlatform-specific
--search-onlyDisable file operationsfalse

Example:

# Start server on port 8080, allow any CORS origin
context-connectors mcp http -i my-project --port 8080 --cors "*"

# With authentication
context-connectors mcp http -i my-project --api-key "secret-key"

# Or use environment variable for the key
MCP_API_KEY="secret-key" context-connectors mcp http -i my-project

About --search-only

By default, all commands provide the list_files and read_file tools in addition to search. Use --search-only to disable file operations and provide only the search tool.

Programmatic Usage

Basic Indexing

import { Indexer } from "@augmentcode/context-connectors";
import { GitHubSource } from "@augmentcode/context-connectors/sources";
import { FilesystemStore } from "@augmentcode/context-connectors/stores";

const source = new GitHubSource({ owner: "myorg", repo: "myrepo" });
const store = new FilesystemStore({ basePath: ".context-connectors" });
const indexer = new Indexer();

const result = await indexer.index(source, store, "my-project");
console.log(`Indexed ${result.filesIndexed} files`);

Search Client

import { SearchClient } from "@augmentcode/context-connectors";
import { FilesystemStore } from "@augmentcode/context-connectors/stores";

const store = new FilesystemStore({ basePath: ".context-connectors" });
const client = new SearchClient({ store, indexName: "my-project" });
await client.initialize(); // Required before calling search()

const result = await client.search("authentication");
console.log(result.results);

Important: You must call await client.initialize() before calling search(). This loads the index state and prepares the client for queries. Calling search() or getMetadata() before initialization will throw a "Client not initialized" error.

MCP Server

import { runMCPServer } from "@augmentcode/context-connectors";
import { FilesystemStore } from "@augmentcode/context-connectors/stores";

const store = new FilesystemStore({ basePath: ".context-connectors" });

await runMCPServer({
  store,
  indexName: "my-project",
});

MCP HTTP Server

import { runMCPHttpServer } from "@augmentcode/context-connectors";
import { FilesystemStore } from "@augmentcode/context-connectors/stores";

const store = new FilesystemStore({ basePath: ".context-connectors" });

const server = await runMCPHttpServer({
  store,
  indexName: "my-project",
  port: 3000,
  host: "0.0.0.0",
  cors: "*",
  apiKey: process.env.MCP_API_KEY,
});

console.log(`MCP server running at ${server.getUrl()}`);

// Graceful shutdown
process.on("SIGTERM", () => server.stop());

Security Considerations

MCP HTTP Server Security

The remote MCP server uses HTTP without TLS by default. This has important security implications:

⚠️ API keys and all data are transmitted in cleartext when using plain HTTP. This means anyone who can observe network traffic (via MITM attacks, network sniffing, etc.) can capture credentials and data.

For Development (localhost only)

When binding to localhost (the default), traffic never leaves your machine:

# Safe: localhost only (default)
context-connectors mcp http -i my-project --api-key "$MCP_API_KEY"

For Production: Use a TLS-Terminating Reverse Proxy

Place the MCP server behind a reverse proxy that handles TLS. Here's an example with Caddy (which automatically obtains certificates):

# Caddyfile
mcp.yourdomain.com {
    reverse_proxy localhost:3000
}

Then run the MCP server on localhost:

context-connectors mcp http -i my-project --api-key "$MCP_API_KEY" --port 3000

Alternative: nginx with Let's Encrypt

server {
    listen 443 ssl;
    server_name mcp.yourdomain.com;
    
    ssl_certificate /etc/letsencrypt/live/mcp.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mcp.yourdomain.com/privkey.pem;
    
    location /mcp {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        
        # For SSE streaming
        proxy_buffering off;
        proxy_cache off;
    }
}

Alternative: SSH Tunneling

For ad-hoc remote access, use SSH port forwarding:

# On the server
context-connectors mcp http -i my-project --api-key "$MCP_API_KEY"

# On your local machine
ssh -L 3000:localhost:3000 user@server

# Now connect to localhost:3000 on your local machine

Network Isolation

If TLS isn't feasible, ensure the server runs within:

  • A private VPC/network with no public internet access
  • A trusted network segment with firewall rules limiting access
  • A Docker network or Kubernetes cluster with network policies

Authentication

Always use an API key for any non-localhost deployment:

# Set via environment variable (recommended - avoids key in shell history)
export MCP_API_KEY="your-secure-random-key"
context-connectors mcp http -i my-project

# Or via command line option
context-connectors mcp http -i my-project --api-key "your-secure-random-key"

Generate a secure key with:

openssl rand -base64 32

Claude Desktop Integration

Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "my-project": {
      "command": "npx",
      "args": ["context-connectors", "mcp", "stdio", "-i", "my-project"],
      "env": {
        "AUGMENT_API_TOKEN": "your-token",
        "AUGMENT_API_URL": "https://your-tenant.api.augmentcode.com/"
      }
    }
  }
}

Remote MCP Client Integration

The mcp http command exposes your indexed data over HTTP using the MCP Streamable HTTP transport. Any MCP-compatible client can connect.

Connecting with MCP SDK

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

const transport = new StreamableHTTPClientTransport(
  new URL("http://localhost:3000/mcp"),
  {
    requestInit: {
      headers: {
        "Authorization": "Bearer your-api-key"
      }
    }
  }
);

const client = new Client({ name: "my-client", version: "1.0.0" });
await client.connect(transport);

// List available tools
const tools = await client.listTools();
console.log(tools);

// Call search tool
const result = await client.callTool("search", { query: "authentication" });
console.log(result);

Testing with curl

# List tools
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-key" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

# Call search tool
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-key" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"search","arguments":{"query":"authentication"}}}'

GitHub Actions

Automate indexing on every push:

name: Index Repository

on:
  push:
    branches: [main]

jobs:
  index:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: "20"

      - name: Index repository
        run: |
          npx @augmentcode/context-connectors index github \
            --owner ${{ github.repository_owner }} \
            --repo ${{ github.event.repository.name }} \
            --ref ${{ github.sha }} \
            -i ${{ github.ref_name }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          AUGMENT_API_TOKEN: ${{ secrets.AUGMENT_API_TOKEN }}
          AUGMENT_API_URL: ${{ secrets.AUGMENT_API_URL }}

GitHub Webhook Integration

Automatically index repositories on push using GitHub webhooks. Supports Vercel/Next.js, Express, and custom frameworks.

Vercel / Next.js App Router

// app/api/webhook/route.ts
import { createVercelHandler } from "@augmentcode/context-connectors/integrations/vercel";
import { S3Store } from "@augmentcode/context-connectors/stores";

const store = new S3Store({ bucket: process.env.INDEX_BUCKET! });

export const POST = createVercelHandler({
  store,
  secret: process.env.GITHUB_WEBHOOK_SECRET!,

  // Only index main branch
  shouldIndex: (event) => event.ref === "refs/heads/main",

  // Log results
  onIndexed: (key, result) => {
    console.log(`Indexed ${key}: ${result.filesIndexed} files`);
  },
});

Express

import express from "express";
import { createExpressHandler } from "@augmentcode/context-connectors/integrations/express";
import { FilesystemStore } from "@augmentcode/context-connectors/stores";

const app = express();
const store = new FilesystemStore({ basePath: "./indexes" });

// Must use raw body for signature verification
app.post(
  "/webhook",
  express.raw({ type: "application/json" }),
  createExpressHandler({
    store,
    secret: process.env.GITHUB_WEBHOOK_SECRET!,
  })
);

app.listen(3000);

Custom Framework

import {
  createGitHubWebhookHandler,
  verifyWebhookSignature
} from "@augmentcode/context-connectors/integrations";
import { S3Store } from "@augmentcode/context-connectors/stores";

const store = new S3Store({ bucket: "my-indexes" });
const handler = createGitHubWebhookHandler({ store, secret: "..." });

// In your request handler:
async function handleRequest(req: Request) {
  const signature = req.headers.get("x-hub-signature-256")!;
  const eventType = req.headers.get("x-github-event")!;
  const body = await req.text();

  if (!await verifyWebhookSignature(body, signature, secret)) {
    return new Response("Unauthorized", { status: 401 });
  }

  const result = await handler(eventType, JSON.parse(body));
  return Response.json(result);
}

GitHub App Setup

  1. Go to Settings > Developer settings > GitHub Apps > New GitHub App
  2. Set webhook URL to your deployed handler
  3. Generate and save the webhook secret
  4. Set Repository contents permission to Read
  5. Subscribe to Push events
  6. Install the app on your repositories

Environment Variables

VariableDescriptionRequired For
AUGMENT_API_TOKENAugment API tokenAll operations
AUGMENT_API_URLAugment API URLAll operations
GITHUB_TOKENGitHub access tokenGitHub source
GITLAB_TOKENGitLab access tokenGitLab source
BITBUCKET_TOKENBitBucket access tokenBitBucket source
GITHUB_WEBHOOK_SECRETWebhook signature secretWebhook integration
OPENAI_API_KEYOpenAI API keyAgent (openai provider)
ANTHROPIC_API_KEYAnthropic API keyAgent (anthropic provider)
GOOGLE_API_KEYGoogle API keyAgent (google provider)
AWS_ACCESS_KEY_IDAWS access keyS3 store
AWS_SECRET_ACCESS_KEYAWS secret keyS3 store
CC_S3_BUCKETS3 bucket nameS3 store
CC_S3_ENDPOINTCustom S3 endpoint URL (for MinIO, etc.)S3-compatible storage
CC_S3_FORCE_PATH_STYLEUse path-style URLs (true/false)S3-compatible storage
MCP_API_KEYAPI key for MCP HTTP server authenticationMCP HTTP server
CONTEXT_CONNECTORS_STORE_PATHOverride default store locationOptional

Data Storage

By default, indexes are stored in ~/.augment/context-connectors/ on all platforms.

This location aligns with other Augment CLI state:

  • ~/.augment/session.json - authentication
  • ~/.augment/settings.json - user settings
  • ~/.augment/rules/ - user rules
  • ~/.augment/agents/ - user-defined agents
  • ~/.augment/commands/ - custom commands

Override with --store-path or the CONTEXT_CONNECTORS_STORE_PATH environment variable.

Architecture

Sources → Indexer → Stores → Clients
  • Sources: Fetch files from data sources (GitHub, GitLab, BitBucket, Website)
  • Indexer: Orchestrates indexing using Augment's context engine
  • Stores: Persist index state (Filesystem, S3)
  • Clients: Consume the index (CLI, Agent, MCP Server via stdio or HTTP)

Filtering

Files are automatically filtered based on:

  1. .augmentignore - Custom ignore patterns (highest priority)
  2. Built-in filters - Binary files, large files, generated code, secrets
  3. .gitignore - Standard git ignore patterns

Create a .augmentignore file to customize:

# Ignore test fixtures
tests/fixtures/

# Ignore generated docs
docs/api/

# Ignore specific files
config.local.json

Note: The .augmentignore file must be placed in the source root directory (the path passed to the add command), not the current working directory.

Website Source

The website source crawls and indexes static HTML content.

Limitations

  • JavaScript-rendered content is not supported. Only static HTML is crawled. Single-page applications (SPAs) or pages that require JavaScript to render content will not be fully indexed.
  • Link-based crawling only - pages must be discoverable through links from the starting URL.

S3-Compatible Storage

When using S3-compatible services like MinIO, DigitalOcean Spaces, or Backblaze B2, configure via environment variables:

export CC_S3_BUCKET=my-bucket
export CC_S3_ENDPOINT=http://localhost:9000
export CC_S3_FORCE_PATH_STYLE=true
export AWS_ACCESS_KEY_ID=minioadmin
export AWS_SECRET_ACCESS_KEY=minioadmin

npx context-connectors index github --owner myorg --repo myrepo -i my-project --store s3
Environment VariableDescription
CC_S3_BUCKETS3 bucket name
CC_S3_ENDPOINTCustom S3 endpoint URL
CC_S3_FORCE_PATH_STYLEUse path-style URLs (true/false, required for MinIO and most S3-compatible services)

License

MIT

版本与发布记录

@augmentcode/context-connectors 共发布 4 个版本,首次发布于 2026/01/14;过去 12 个月发布了 4 个版本。

版本发布日期距今
0.1.4latest2026/02/118 个月前
0.1.32026/01/149 个月前
0.1.22026/01/149 个月前
0.1.12026/01/149 个月前

关于 @augmentcode/context-connectors 的常见问题

@augmentcode/context-connectors 是什么?

Modular system for indexing any data source and making it searchable via Augment's context engine

如何安装 @augmentcode/context-connectors?

在项目目录运行 npm install @augmentcode/context-connectors,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 ctxc,可以用 npx ctxc 直接运行。

@augmentcode/context-connectors 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@augmentcode/context-connectors 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@augmentcode/context-connectors 可以商用吗?

@augmentcode/context-connectors 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@augmentcode/context-connectors 的下载量有多少?

根据 npm 官方下载统计,@augmentcode/context-connectors 在 2026/10/07 – 2026/11/05 这 30 天内被下载 1,864 次,日均约 62 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@augmentcode/context-connectors 还在维护吗?

最新版本 0.1.4 发布于 2026/02/11(8 个月前);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/01/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。