Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
55dcf41
Initial CLI/proxy wrapper PoC
voarsh Dec 8, 2025
567c866
Introduces session defaults to indexer calls
voarsh Dec 8, 2025
f45dda5
Enables proxying tools to a memory MCP server
voarsh Dec 8, 2025
70b6257
ctxce cli - rename to mcp bridge
voarsh Dec 8, 2025
5242b06
Update gitignore
voarsh Dec 8, 2025
02fafd9
Renames package and adds publish script
voarsh Dec 8, 2025
3cd07f8
mcp bridge: Updates publish workflow to new CLI package name
voarsh Dec 8, 2025
395d049
fix: harden MCP bridge tools/list handling on Windows
voarsh Dec 8, 2025
2ac9d53
Merge branch 'test' into cli-fascade
voarsh Dec 8, 2025
896cd34
bridge: chmod publish script
voarsh Dec 9, 2025
10f9a2b
mcp bridge poc: extension mcp config wiring (stdio)
voarsh Dec 9, 2025
89ba27e
Add HTTP MCP bridge and IDE auto-wiring
voarsh Dec 9, 2025
94d74c7
vscode ext: Refactors MCP config and bridge management
voarsh Dec 9, 2025
3c1ce33
feat(ctx-mcp-bridge): Add CTXCE_TOOL_TIMEOUT_MSEC env var for tool ti…
voarsh Dec 9, 2025
9b54f90
feat(ctx-mcp-bridge): Exit bridge process when stdin is closed
voarsh Dec 9, 2025
64a90a1
feat(vscode-extension): Allow configuring MCP bridge binary path and …
voarsh Dec 9, 2025
17bbe1b
MCP Bridge: version bump
voarsh Dec 9, 2025
5fa80c6
Merge branch 'test' into cli-fascade
voarsh Dec 10, 2025
74d75aa
Bridge: Handles MCP session errors with client reinitialization
voarsh Dec 10, 2025
9338d40
Bridge: Improves tool call reliability with retries
voarsh Dec 10, 2025
3098828
feat: Introduce MCP bridge for auth and session management
voarsh Dec 11, 2025
d9101e8
fix: Propagate auth config to docker-compose
voarsh Dec 11, 2025
49245c0
fix: Update remote upload clients to use auth sessions
voarsh Dec 11, 2025
0a3f337
fix: Enable smart symbol reindexing by default
voarsh Dec 11, 2025
a03e636
feat: Remove scaffolding from writeMcpConfig and add default llama cp…
voarsh Dec 11, 2025
ef0e103
fix: bump extension version
voarsh Dec 11, 2025
2bd65f5
Merge branch 'test' into cli-fascade
voarsh Dec 11, 2025
ca52723
fix: stop mangling MCP URLs in bridge mode
voarsh Dec 11, 2025
b37a561
Fix: Windsurf HTTP bridge hot reload mcp config
voarsh Dec 11, 2025
9f231e8
fix(upload-service): prevent recursive dev-workspace nesting and env-…
voarsh Dec 11, 2025
07220b6
fix(extension): bundle auth helper and decouple standalone upload client
voarsh Dec 11, 2025
eca498f
chore(extension): declare MCP bridge commands in package.json
voarsh Dec 11, 2025
fc3fb0f
fix(extension): honor configured MCP indexer URL in Prompt+ ctx invoc…
voarsh Dec 11, 2025
d1b85be
feat(auth): Allow unauthenticated login for development
voarsh Dec 11, 2025
cc51799
feat(mcp-bridge): Propagate session ID to MCP indexer server
voarsh Dec 11, 2025
d16d1c6
feat(ctx): Add GLM runtime support for plan generation and improve er…
voarsh Dec 11, 2025
e4fc9a2
fix(mcp_router): Tolerate missing session id header in MCP handshake
voarsh Dec 11, 2025
c53b51b
fix(upload_client): Special-case 401 errors in upload clients
voarsh Dec 11, 2025
18c48f7
fix(vscode-extension): Update dependencies in vscode extension build …
voarsh Dec 11, 2025
f6123ca
MCP bridge: version bump
voarsh Dec 11, 2025
197e42f
fix(mcp-indexer): allow clearing session defaults via empty strings
voarsh Dec 11, 2025
ef30572
mcp bridge: Remaps tool result paths to workspace-relative
voarsh Dec 12, 2025
27189cb
feat: implement collection registry and ACL
voarsh Dec 12, 2025
492010e
feat: add admin UI for user and collection ACL management
voarsh Dec 12, 2025
21683bb
fix: init container chmod and user
voarsh Dec 12, 2025
9c041e7
feat: enable auth env vars for init container
voarsh Dec 12, 2025
eef7452
feat: set HNSW index params when creating collections
voarsh Dec 12, 2025
6f4296b
feat: mcp memory server fastembed cache
voarsh Dec 12, 2025
ff00503
feat: Enforce collection access on memory find and store endpoints an…
voarsh Dec 12, 2025
d52ccb3
fix: mcp_indexer_server require session for index commands
voarsh Dec 12, 2025
016f248
fix: memory_restore output
voarsh Dec 12, 2025
71ee135
fix: mcp_indexer_server enforce auth for search commands
voarsh Dec 12, 2025
ec60fe1
k8: update configmap, env/sample update, fix memory mcp crash
voarsh Dec 12, 2025
4a97498
fix(auth): restore session DB init + fail closed if auth backend impo…
voarsh Dec 12, 2025
9a27650
Fix repo_search rerank to respect explicit Qdrant collection
voarsh Dec 12, 2025
896e4a5
fix: enhance security with upload_service and stability
voarsh Dec 12, 2025
f5826df
mcp bridge: improve path mapping and workspace-relative handling
voarsh Dec 12, 2025
2f23704
test(ci): avoid FastAPI dependency by extracting delta bundle processing
voarsh Dec 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ REFRAG_RUNTIME=llamacpp
REFRAG_ENCODER_MODEL=BAAI/bge-base-en-v1.5
REFRAG_PHI_PATH=/work/models/refrag_phi_768_to_dmodel.bin
REFRAG_SENSE=heuristic
REFRAG_PSEUDO_DESCRIBE=1
GLM_API_KEY=
# Llama.cpp sidecar (optional)
# Use docker network hostname from containers; localhost remains ok for host-side runs if LLAMACPP_URL not exported
LLAMACPP_URL=http://host.docker.internal:8081
LLAMACPP_TIMEOUT_SEC=300
DECODER_MAX_TOKENS=4000
REFRAG_DECODER_MODE=prompt # prompt|soft
REFRAG_COMMIT_DESCRIBE=1

REFRAG_SOFT_SCALE=1.0
LLAMACPP_USE_GPU=1
Expand All @@ -149,6 +151,8 @@ MAX_MICRO_CHUNKS_PER_FILE=500
QDRANT_TIMEOUT=20
MEMORY_AUTODETECT=1
MEMORY_COLLECTION_TTL_SECS=300
SMART_SYMBOL_REINDEXING=1
MAX_CHANGED_SYMBOLS_RATIO=0.6


# Watcher-safe defaults (recommended)
Expand Down Expand Up @@ -196,4 +200,9 @@ INFO_REQUEST_LIMIT=10
INFO_REQUEST_CONTEXT_LINES=5
# INFO_REQUEST_EXPLAIN_DEFAULT=0
# INFO_REQUEST_RELATIONSHIPS=0
GLM_API_BASE=https://api.z.ai/api/coding/paas/v4/
GLM_MODEL=glm-4.6
COMMIT_VECTOR_SEARCH=0
STRICT_MEMORY_RESTORE=1
CTXCE_AUTH_ENABLED=0
CTXCE_AUTH_ADMIN_TOKEN=change-me-admin-token
64 changes: 61 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ REFRAG_PHI_PATH=/work/models/refrag_phi_768_to_dmodel.json
REFRAG_SENSE=heuristic

# Enable index-time pseudo descriptions for micro-chunks (requires REFRAG_DECODER)
# REFRAG_PSEUDO_DESCRIBE=1
REFRAG_PSEUDO_DESCRIBE=1

# Llama.cpp sidecar (optional)
# Docker CPU-only (stable): http://llamacpp:8080
Expand Down Expand Up @@ -189,7 +189,8 @@ MEMORY_AUTODETECT=1
MEMORY_COLLECTION_TTL_SECS=300

# Smarter re-indexing for symbol cache, reuse embeddings and reduce decoder/pseudo tags to re-index
SMART_SYMBOL_REINDEXING=0
SMART_SYMBOL_REINDEXING=1
MAX_CHANGED_SYMBOLS_RATIO=0.6

# Watcher-safe defaults (recommended)
# Applied to watcher via compose; uncomment to apply globally.
Expand Down Expand Up @@ -226,7 +227,7 @@ SMART_SYMBOL_REINDEXING=0
REFRAG_COMMIT_DESCRIBE=1
COMMIT_VECTOR_SEARCH=0

STRICT_MEMORY_RESTORE=0
STRICT_MEMORY_RESTORE=1

# info_request() tool settings (simplified codebase retrieval)
# Default result limit for info_request queries
Expand All @@ -237,3 +238,60 @@ INFO_REQUEST_CONTEXT_LINES=5
# INFO_REQUEST_EXPLAIN_DEFAULT=0
# Enable relationship mapping by default (imports_from, calls, related_paths)
# INFO_REQUEST_RELATIONSHIPS=0


# ---------------------------------------------------------------------------
# Optional Auth & Bridge Configuration (OFF by default)
# ---------------------------------------------------------------------------

# Global auth toggle for backend services (upload_service, MCP indexer/memory).
# When set to 1, services will require a valid session for protected operations.
# When unset or 0, auth is disabled and behavior matches previous versions.
# CTXCE_AUTH_ENABLED=0

# Shared token used by /auth/login for the bridge and other service clients.
# When CTXCE_AUTH_ENABLED=1 and this is set, /auth/login will only issue
# sessions when the provided token matches this value.
# CTXCE_AUTH_SHARED_TOKEN=change-me-dev-token

# Create "open-dev" tokens when a shared token is unset, basically allows requesting a session with no real auth
# CTXCE_AUTH_ALLOW_OPEN_TOKEN_LOGIN=0

# Optional admin token for creating additional users via /auth/users once the
# first user has been bootstrapped. If unset, only the initial user can be
# created (no additional users).
# CTXCE_AUTH_ADMIN_TOKEN=change-me-admin-token

# Auth database location (default: sqlite file under WORK_DIR/.codebase).
# Use a SQLite URL for local/dev, or point to a different path.
# CTXCE_AUTH_DB_URL=sqlite:////work/.codebase/ctxce_auth.sqlite

# Session TTL (seconds) for issued auth sessions.
# 0 or negative values disable expiry (sessions do not expire). When >0,
# active sessions are extended with a sliding window whenever they are used.
# CTXCE_AUTH_SESSION_TTL_SECONDS=0

# Collection registry & ACL (only used when CTXCE_AUTH_ENABLED=1).
# When enabled, infrastructure/health checks may populate an internal SQLite
# registry of known Qdrant collections, and ACL rules can be applied by services.

# ACL bypass (dev/early deployments): allow all users to access all collections.
# CTXCE_ACL_ALLOW_ALL=0

# MCP boundary enforcement (OFF by default).
# When enabled, MCP servers will enforce collection ACLs using the auth DB.
# Requires CTXCE_AUTH_ENABLED=1. If CTXCE_ACL_ALLOW_ALL=1, enforcement is bypassed.
# This is intended for gradually rolling out collection-level permissions without
# changing existing client auth/session mechanisms.
# CTXCE_MCP_ACL_ENFORCE=0

# Bridge-side configuration (ctx-mcp-bridge):
# The bridge will POST to this URL for auth login and store the returned
# session id, then inject it into all MCP tool calls as the `session` field.
# CTXCE_AUTH_BACKEND_URL=http://localhost:8004

# Optional defaults for bridge CLI (env) auth:
# CTXCE_AUTH_TOKEN=dev-shared-token
# CTXCE_AUTH_USERNAME=you@example.com
# CTXCE_AUTH_PASSWORD=your-password

34 changes: 34 additions & 0 deletions .github/workflows/publish-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish ctxce CLI to npm

on:
workflow_dispatch:
inputs:
version:
description: "Version to publish (ensure package.json is updated)"
required: false
push:
tags:
- "ctxce-cli-v*"

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
working-directory: ctx-mcp-bridge
run: npm install

- name: Publish to npm
working-directory: ctx-mcp-bridge
run: npm publish --access public --provenance
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Model artifacts
models/

# Node
node_modules/

# Qdrant snapshots
qdrant/snapshots/

Expand Down
1 change: 1 addition & 0 deletions ctx-mcp-bridge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.tgz
212 changes: 212 additions & 0 deletions ctx-mcp-bridge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# Context Engine MCP Bridge

`@context-engine-bridge/context-engine-mcp-bridge` provides the `ctxce` CLI, a
Model Context Protocol (MCP) bridge that speaks to the Context Engine indexer
and memory servers and exposes them as a single MCP server.

It is primarily used by the VS Code **Context Engine Uploader** extension,
available on the Marketplace:

- <https://marketplace.visualstudio.com/items?itemName=context-engine.context-engine-uploader>

The bridge can also be run standalone (e.g. from a terminal, or wired into
other MCP clients) as long as the Context Engine stack is running.

## Prerequisites

- Node.js **>= 18** (see `engines` in `package.json`).
- A running Context Engine stack (e.g. via `docker-compose.dev-remote.yml`) with:
- MCP indexer HTTP endpoint (default: `http://localhost:8003/mcp`).
- MCP memory HTTP endpoint (optional, default: `http://localhost:8002/mcp`).
- For optional auth:
- The upload/auth services must be configured with `CTXCE_AUTH_ENABLED=1` and
a reachable auth backend URL (e.g. `http://localhost:8004`).

## Installation

You can install the package globally, or run it via `npx`.

### Global install

```bash
npm install -g @context-engine-bridge/context-engine-mcp-bridge
```

This installs the `ctxce` (and `ctxce-bridge`) CLI in your PATH.

### Using npx (no global install)

```bash
npx @context-engine-bridge/context-engine-mcp-bridge ctxce --help
```

The examples below assume `ctxce` is available on your PATH; if you use `npx`,
just prefix commands with `npx @context-engine-bridge/context-engine-mcp-bridge`.

## CLI overview

The main entrypoint is:

```bash
ctxce <command> [...args]
```

Supported commands (from `src/cli.js`):

- `ctxce mcp-serve` – stdio MCP bridge (for stdio-based MCP clients).
- `ctxce mcp-http-serve` – HTTP MCP bridge (for HTTP-based MCP clients).
- `ctxce auth <subcmd>` – auth helper commands (`login`, `status`, `logout`).

### Environment variables

These environment variables are respected by the bridge:

- `CTXCE_INDEXER_URL` – MCP indexer URL (default: `http://localhost:8003/mcp`).
- `CTXCE_MEMORY_URL` – MCP memory URL, or empty/omitted to disable memory
(default: `http://localhost:8002/mcp`).
- `CTXCE_HTTP_PORT` – port for `mcp-http-serve` (default: `30810`).

For auth (optional, shared with the upload/auth backend):

- `CTXCE_AUTH_ENABLED` – whether auth is enabled in the backend.
- `CTXCE_AUTH_BACKEND_URL` – auth backend URL (e.g. `http://localhost:8004`).
- `CTXCE_AUTH_TOKEN` – dev/shared token for `ctxce auth login`.
- `CTXCE_AUTH_SESSION_TTL_SECONDS` – session TTL / sliding expiry (seconds).

The CLI also stores auth sessions in `~/.ctxce/auth.json`, keyed by backend URL.

## Running the MCP bridge (stdio)

The stdio bridge is suitable for MCP clients that speak stdio directly (for
example, certain editors or tools that expect an MCP server on stdin/stdout).

```bash
ctxce mcp-serve \
--workspace /path/to/your/workspace \
--indexer-url http://localhost:8003/mcp \
--memory-url http://localhost:8002/mcp
```

Flags:

- `--workspace` / `--path` – workspace root (default: current working directory).
- `--indexer-url` – override indexer URL (default: `CTXCE_INDEXER_URL` or
`http://localhost:8003/mcp`).
- `--memory-url` – override memory URL (default: `CTXCE_MEMORY_URL` or
disabled when empty).

## Running the MCP bridge (HTTP)

The HTTP bridge exposes the MCP server via an HTTP endpoint (default
`http://127.0.0.1:30810/mcp`) and is what the VS Code extension uses in its
`http` transport mode.

```bash
ctxce mcp-http-serve \
--workspace /path/to/your/workspace \
--indexer-url http://localhost:8003/mcp \
--memory-url http://localhost:8002/mcp \
--port 30810
```

Flags:

- `--workspace` / `--path` – workspace root (default: current working directory).
- `--indexer-url` – MCP indexer URL.
- `--memory-url` – MCP memory URL (or omit/empty to disable memory).
- `--port` – HTTP port for the bridge (default: `CTXCE_HTTP_PORT`
or `30810`).

Once running, you can point an MCP client at:

```text
http://127.0.0.1:<port>/mcp
```

## Auth helper commands (`ctxce auth ...`)

These commands are used both by the VS Code extension and standalone flows to
log in and manage auth sessions for the backend.

### Login (token)

```bash
ctxce auth login \
--backend-url http://localhost:8004 \
--token $CTXCE_AUTH_SHARED_TOKEN
```

This hits the backend `/auth/login` endpoint and stores a session entry in
`~/.ctxce/auth.json` under the given backend URL.

### Login (username/password)

```bash
ctxce auth login \
--backend-url http://localhost:8004 \
--username your-user \
--password your-password
```

This calls `/auth/login/password` and persists the returned session the same
way as the token flow.

### Status

Human-readable status:

```bash
ctxce auth status --backend-url http://localhost:8004
```

Machine-readable status (used by the VS Code extension):

```bash
ctxce auth status --backend-url http://localhost:8004 --json
```

The `--json` variant prints a single JSON object to stdout, for example:

```json
{
"backendUrl": "http://localhost:8004",
"state": "ok", // "ok" | "missing" | "expired" | "missing_backend"
"sessionId": "...",
"userId": "user-123",
"expiresAt": 0 // 0 or a Unix timestamp
}
```

Exit codes:

- `0` – `state: "ok"` (valid session present).
- `1` – `state: "missing"` or `"missing_backend"`.
- `2` – `state: "expired"`.

### Logout

```bash
ctxce auth logout --backend-url http://localhost:8004
```

Removes the stored auth entry for the given backend URL from
`~/.ctxce/auth.json`.

## Relationship to the VS Code extension

The VS Code **Context Engine Uploader** extension is the recommended way to use
this bridge for day-to-day development. It:

- Launches the standalone upload client to push code into the remote stack.
- Starts/stops the MCP HTTP bridge (`ctxce mcp-http-serve`) for the active
workspace when `autoStartMcpBridge` is enabled.
- Uses `ctxce auth status --json` and `ctxce auth login` under the hood to
manage user sessions via UI prompts.

This package README is aimed at advanced users who want to:

- Run the MCP bridge outside of VS Code.
- Integrate the Context Engine MCP servers with other MCP-compatible clients.

You can safely mix both approaches: the extension and the standalone bridge
share the same auth/session storage in `~/.ctxce/auth.json`.
7 changes: 7 additions & 0 deletions ctx-mcp-bridge/bin/ctxce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env node
import { runCli } from "../src/cli.js";

runCli().catch((err) => {
console.error("[ctxce] Fatal error:", err && err.stack ? err.stack : err);
process.exit(1);
});
Loading
Loading