MCP Server Reference

The @lightfastai/mcp package provides a Model Context Protocol server that exposes Lightfast tools to AI assistants.

Installation

bash
npx @lightfastai/mcp
# or
npm install -g @lightfastai/mcp

CLI Options

bash
npx @lightfastai/mcp [options]
OptionTypeDefaultDescription
--api-keystring$LIGHTFAST_API_KEYLightfast API key
--base-urlstringhttps://lightfast.aiAPI base URL
--help, -h--Show help message
--version, -v--Show version

Environment Variables

VariableDescription
LIGHTFAST_API_KEYAPI key (alternative to --api-key flag)

Tools

The MCP server exposes three tools to AI assistants.

Search through workspace memory for relevant documents and observations.

Parameters

NameTypeRequiredDefaultDescription
querystringYes-Natural language search query
limitnumberNo10Number of results to return
modestringNo"balanced"Search mode: "fast", "balanced", or "quality"
filtersobjectNo-Filter object with sources and dateRange

Example Request

json
{
  "name": "lightfast_search",
  "arguments": {
    "query": "how does authentication work",
    "limit": 5,
    "mode": "quality"
  }
}

Response Schema

typescript
{
  results: Array<{
    id: string;
    type: string;
    title: string;
    snippet: string;
    score: number;
    source: string;
    url: string;
  }>;
  meta: {
    total: number;
    latency: { total: number };
  };
}

lightfast_contents

Fetch full content for documents by their IDs.

Parameters

NameTypeRequiredDescription
idsstring[]YesArray of document IDs to fetch

Example Request

json
{
  "name": "lightfast_contents",
  "arguments": {
    "ids": ["doc_abc123", "doc_def456"]
  }
}

Response Schema

typescript
{
  items: Array<{
    id: string;
    type: string;
    title: string;
    content: string;
    metadata: Record<string, unknown>;
  }>;
  missing: string[];
}

lightfast_find_similar

Find content semantically similar to a given document or URL.

Parameters

NameTypeRequiredDefaultDescription
idstringOne of id/url-Document ID
urlstringOne of id/url-URL to find similar content for
limitnumberNo10Number of results
thresholdnumberNo0.5Minimum similarity score (0-1)

Example Request

json
{
  "name": "lightfast_find_similar",
  "arguments": {
    "url": "https://github.com/org/repo/pull/123",
    "limit": 5,
    "threshold": 0.7
  }
}

Response Schema

typescript
{
  results: Array<{
    id: string;
    type: string;
    title: string;
    snippet: string;
    score: number;
    source: string;
    url: string;
  }>;
  source: {
    id: string;
    title: string;
    type: string;
  };
}

Error Responses

All tools return errors in the following format:

json
{
  "error": "ERROR_CODE",
  "message": "Human-readable error message",
  "requestId": "req_abc123"
}
Error CodeDescription
UNAUTHORIZEDInvalid or missing API key
VALIDATION_ERRORInvalid parameters
NOT_FOUNDResource not found
INTERNAL_ERRORServer error