सेल्फ-होस्टेड टीम सर्वर
एक सिंगल, सेल्फ-होस्टेड HTTP सर्वर के ज़रिए अपनी टीम के साथ सभी 58 lean-ctx MCP टूल्स शेयर करें। टोकन-आधारित प्रमाणीकरण, वर्कस्पेस आइसोलेशन, रेट लिमिटिंग, और पूर्ण ऑडिट लॉगिंग - lean-ctx को केंद्रीय रूप से चलाने के लिए सब कुछ।
Prerequisites
- LeanCTX installed on each developer's machine (Installation Guide)
- Docker (for containerized deployment) or a Linux/macOS server
- Network connectivity between developer machines and the server
त्वरित शुरुआत (4 चरण)
5 मिनट से कम में टीम सर्वर चालू करें। आवश्यक: lean-ctx बाइनरी (--all-features के साथ बिल्ड) और एक JSON कॉन्फ़िगरेशन फ़ाइल।
1. कॉन्फ़िगरेशन फ़ाइल बनाएँ (team.json)
{
"host": "0.0.0.0",
"port": 9877,
"defaultWorkspaceId": "main",
"auditLogPath": "/var/log/lean-ctx/audit.log",
"workspaces": [
{
"id": "main",
"label": "Main Project",
"root": "/home/team/project"
}
],
"tokens": []
} 2. API टोकन जनरेट करें
# Generate a token with specific scopes
TOKEN="$(lean-ctx team token create \
--config team.json \
--id dev-alice \
--scopes search,graph,artifacts,index,events,sessionMutations,knowledge
)"
# TOKEN is the Bearer token (printed once; config stores only sha256Hex). 3. सर्वर शुरू करें
lean-ctx team serve --config team.json
# Team Server - 0.0.0.0:9877
# Workspaces: 1 (main)
# Tokens: 1 active
# Tools: 58 available 4. किसी भी क्लाइंट से कनेक्ट करें
# Health check
curl http://your-server:9877/health
# List available tools (requires token)
curl -H "Authorization: Bearer $TOKEN" \
http://your-server:9877/v1/manifest
# Call a tool (workspace defaults to defaultWorkspaceId)
curl -X POST -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"ctx_tree","arguments":{"path":".","depth":2}}' \
http://your-server:9877/v1/tools/call
# Call a tool in a specific workspace (header overrides default)
curl -X POST -H "Authorization: Bearer $TOKEN" \
-H "x-leanctx-workspace: main" \
-H "Content-Type: application/json" \
-d '{"name":"ctx_read","arguments":{"path":"README.md","mode":"signatures"}}' \
http://your-server:9877/v1/tools/call Docker Deployment
Run the Team Server as a Docker container for quick deployment without compiling from source.
docker run -d --name leanctx-team \
-p 7700:7700 \
-v leanctx-data:/data \
ghcr.io/yvgude/lean-ctx:latest \
serve --team --data-dir /data Or run directly from the binary:
lean-ctx serve --team --bind 0.0.0.0:7700 --data-dir ./team-data Verify the server is running:
curl http://your-server:7700/healthz
# {"status":"ok","version":"3.5.1","uptime":"2m"} कॉन्फ़िगरेशन संदर्भ
टीम सर्वर एक सिंगल JSON फ़ाइल से कॉन्फ़िगर होता है। सभी सेटिंग्स बिना रीस्टार्ट के बदली जा सकती हैं - बस फ़ाइल बदलें और सर्वर रीस्टार्ट करें।
| फ़ील्ड | टाइप | विवरण | डिफ़ॉल्ट |
|---|---|---|---|
host | string | बाइंड एड्रेस (रिमोट एक्सेस के लिए 0.0.0.0 का उपयोग करें) | 127.0.0.1 |
port | u16 | HTTP पोर्ट | 9877 |
defaultWorkspaceId | string | अनुरोध में निर्दिष्ट न होने पर डिफ़ॉल्ट वर्कस्पेस | - |
auditLogPath | path | JSON Lines ऑडिट लॉग फ़ाइल का पाथ | - |
disableHostCheck | bool | ऑरिजिन/होस्ट हेडर वैलिडेशन अक्षम करें (केवल डेवलपमेंट के लिए) | false |
allowedHosts | string[] | CORS के लिए अनुमत ऑरिजिन होस्टनेम | [] |
maxBodyBytes | usize | अधिकतम अनुरोध बॉडी साइज़ बाइट्स में (डिफ़ॉल्ट: 10 MB) | 2097152 |
maxConcurrency | usize | अधिकतम समवर्ती अनुरोध | 32 |
maxRps | u32 | प्रति सेकंड अधिकतम अनुरोध | 50 |
rateBurst | u32 | maxRps से ऊपर बर्स्ट क्षमता (छोटी स्पाइक्स को अवशोषित करती है) | 100 |
requestTimeoutMs | u64 | अनुरोध टाइमआउट मिलीसेकंड में | 30000 |
टोकन और स्कोप
प्रत्येक टीम सदस्य को सूक्ष्म स्कोप वाला एक यूनिक API टोकन मिलता है। टोकन SHA-256 हैश के रूप में कॉन्फ़िग फ़ाइल में स्टोर होते हैं - प्लेनटेक्स्ट टोकन केवल निर्माण के समय एक बार दिखाया जाता है।
उपलब्ध स्कोप
| स्कोप | विवरण |
|---|---|
search | रीड टूल्स: ctx_read, ctx_search, ctx_tree, ctx_overview, ctx_pack, ctx_proof, ctx_verify, और सभी रीड-ओरिएंटेड टूल्स |
graph | ग्राफ टूल्स: ctx_graph, ctx_graph_diagram, ctx_impact, ctx_callgraph, ctx_callers, ctx_callees, ctx_routes |
artifacts | ctx_artifacts, ctx_semantic_search (artifacts=true के साथ) |
index | ग्राफ इंडेक्स बिल्ड (ctx_graph action=index-build*), सिमेंटिक रीइंडेक्स |
events | SSE इवेंट स्ट्रीम पर सब्सक्राइब करें (GET /v1/events) |
sessionMutations | सेशन राइट्स: ctx_session (save, task, checkpoint, decision, reset), ctx_handoff, ctx_workflow, ctx_share |
knowledge | नॉलेज राइट्स: ctx_knowledge (remember, feedback, remove, consolidate), ctx_knowledge_relations |
audit | GET /v1/metrics, पूर्ण पेलोड इवेंट एक्सेस, ऑडिट लॉग रीड |
# Create token with all scopes
lean-ctx team token create \
--config team.json \
--id ci-bot \
--scopes search,graph,artifacts,index,events,sessionMutations,knowledge,audit
# Create read-only token (search + graph only)
lean-ctx team token create \
--config team.json \
--id reviewer \
--scopes search,graph
# Create agent token (read + write + events)
lean-ctx team token create \
--config team.json \
--id agent-alice \
--scopes search,graph,events,sessionMutations,knowledge टोकन स्टोर करने से पहले SHA-256 से हैश किए जाते हैं। प्लेनटेक्स्ट निर्माण के समय stdout पर एक बार प्रिंट होता है। यदि आप टोकन खो देते हैं, तो नया जनरेट करें - मूल टोकन रिकवर करने का कोई तरीका नहीं है।
Connecting Agents
Each developer configures their local LeanCTX to connect to the Team Server via a config file or environment variables.
Add to .lean-ctx/config.toml:
[team]
server = "http://your-server:7700"
token = "lctx_t_alice_a3f8..."
workspace = "my-team" Or set via environment variables:
export LEANCTX_TEAM_SERVER="http://your-server:7700"
export LEANCTX_TEAM_TOKEN="lctx_t_alice_a3f8..."
export LEANCTX_WORKSPACE="my-team" मल्टी-वर्कस्पेस सेटअप
एक सिंगल सर्वर इंस्टेंस से कई प्रोजेक्ट्स सर्व करें। प्रत्येक वर्कस्पेस एक अलग प्रोजेक्ट रूट डायरेक्टरी को पॉइंट करता है और अपना ग्राफ इंडेक्स और सेशन स्टेट बनाए रखता है।
{
"workspaces": [
{ "id": "frontend", "label": "React Frontend", "root": "/srv/frontend" },
{ "id": "backend", "label": "Rust API", "root": "/srv/backend" },
{ "id": "infra", "label": "Infrastructure", "root": "/srv/infra" }
],
"defaultWorkspaceId": "frontend"
} क्लाइंट अपने अनुरोधों में <code>X-Workspace</code> हेडर जोड़कर वर्कस्पेस चुनते हैं। यदि छोड़ दिया जाए, तो <code>defaultWorkspaceId</code> का उपयोग होता है।
Shared Sessions
Once connected, sessions are automatically shared. Agents on the same workspace and channel see each other's context in real time.
lean-ctx session list --workspace my-team
# workspace: my-team
# channel: feat/auth-refactor rev:14 agents: cursor, claude-code
# channel: fix/api-timeout rev:7 agents: windsurf
# channel: main rev:42 agents: copilot, kiro Governance & Budgets
Configure per-agent budgets, roles, and policies in your team profile to control spending and access.
[budget]
max_context_tokens = 200000
max_cost_usd = 5.0
alert_threshold = 0.8
[roles]
default = "developer"
[roles.ci]
scope = "read"
max_cost_usd = 1.0 Monitoring
The Team Server exposes Prometheus metrics and a status endpoint. Use the observatory dashboard for a visual overview.
lean-ctx observatory --open प्रमाणीकरण
हर अनुरोध (/health को छोड़कर) के लिए Authorization हेडर में एक वैध Bearer टोकन आवश्यक है। सर्वर कॉन्फ़िग फ़ाइल में SHA-256 हैश के विरुद्ध टोकन को सत्यापित करता है और जाँचता है कि टोकन के स्कोप अनुरोधित टूल को कवर करते हैं।
Authorization: Bearer $TOKEN
# Without token → HTTP 401 + JSON {error_code:"unauthorized", ...}
# Invalid token → HTTP 401 + JSON {error_code:"unauthorized", ...}
# Valid token, wrong scope → HTTP 403 + JSON {error_code:"scope_denied", ...} रेट लिमिट और सुरक्षा
टीम सर्वर में बिल्ट-इन रेट लिमिटिंग, कंकरेंसी कंट्रोल, रिक्वेस्ट साइज़ लिमिट, और टाइमआउट शामिल हैं। ये बेकाबू Agent और आकस्मिक सर्विस डिनायल से सुरक्षा करते हैं।
{
"maxRps": 50,
"rateBurst": 100,
"maxConcurrency": 32,
"requestTimeoutMs": 30000,
"maxBodyBytes": 2097152
} ऑडिट लॉग
हर प्रमाणित टूल कॉल JSON Lines फ़ाइल में लॉग होती है। प्रत्येक एंट्री में टाइमस्टैम्प, टोकन ID, टूल का नाम, वर्कस्पेस, अवधि, और स्थिति शामिल है। डीबगिंग, अनुपालन, और लागत एट्रिब्यूशन के लिए उपयोग करें।
Audit log is JSONL (one JSON object per line). It never stores raw tool arguments — only
argumentsMd5 of a canonicalized JSON representation.
# Inspect the latest audit entry
tail -n 1 /var/log/lean-ctx/audit.log | jq .
# Keys per entry:
# ts, tokenId, workspaceId, tool, method, allowed, deniedReason, argumentsMd5 वर्कस्पेस सिंक
सिंक कमांड चलाकर वर्कस्पेस इंडेक्स को अपडेट रखें। यह प्रत्येक वर्कस्पेस पर git fetch करता है और पुराने ग्राफ इंडेक्स को रीबिल्ड करता है। पूरी तरह स्वचालित टीम वर्कफ़्लो के लिए cron या CI जॉब से चलाएँ।
# Sync all workspaces (git fetch + rebuild indexes)
lean-ctx team sync --config team.json
# Sync a specific workspace
lean-ctx team sync --config team.json --workspace backend Next Steps
- API Reference — REST endpoints and SDK
- Profiles — Preconfigured governance presets
- Shared Sessions — Deep dive into session sharing
- Context Bus — Event-driven multi-agent coordination
- Remote Setup — Advanced remote deployment options
- Observatory — Dashboard & monitoring