-
Notifications
You must be signed in to change notification settings - Fork 4
MCP Server and lwc explore
Language: English · 简体中文
LWC exposes one standard MCP server entry named lwc. It combines bounded Wiki memory and optional CodeGraph exploration behind one read-only tool, lwc_explore.
CodeGraph is internal to the LWC MCP. Agent hosts should not register a second codegraph server for LWC-managed projects.
The Agent host starts a foreground MCP process over JSON-RPC on standard input and output:
lwc serve --mcp --path /absolute/path/to/projectIf --path is omitted, LWC binds to the process working directory. AgentTarget installers write the appropriate official host configuration and invoke the global lwc command from PATH; users normally do not run the transport manually.
The server supports MCP initialization, tools/list, tools/call, and ping. It exits when the host closes its input.
tools/list returns exactly one tool:
lwc_explore
Its annotations declare:
- read-only:
true; - destructive:
false; - idempotent:
true; - open-world:
false.
The tool never initializes a Wiki, enables a document graph, downloads CodeGraph, creates a project index, converts files, or writes memory. Missing readiness produces guidance for an explicit CLI action outside MCP.
| Field | Required | Default | Bound |
|---|---|---|---|
query |
Yes | — | 1–10,000 characters |
projectPath |
Yes | — | Absolute existing authorized directory |
mode |
No | memory |
memory, code, or all
|
scope |
No | all |
project, global, or all
|
maxDocuments |
No | 8 |
1–20 |
maxFiles |
No | 12 |
1–20 |
Unknown fields are rejected. Request frames larger than 64 KiB are rejected without stopping the server.
The projectPath must stay inside the MCP host workspace selected at startup. LWC rejects relative paths, symlinked project boundaries, filesystem roots, home or temporary roots, sensitive system roots, and sibling paths outside the host workspace.
mode=memory is the bounded default. It:
- performs deterministic
autodocument search in the selected scope; - returns ranked Page and Source metadata up to
maxDocuments; - opens only matching Page bodies—not raw Source bodies;
- caps each Page at 15,000 characters and all returned Page bodies at 60,000 characters;
- reports passive document-graph readiness;
- adds one bounded related-Page neighborhood when a ready graph and Page seed exist.
Page results include scope, slug, title, kind, summary, body, provenance, links, and a truncation flag. Source results remain metadata until the Agent deliberately uses audited CLI Source reads.
Use memory mode for prior decisions, maintained knowledge, evidence discovery, and project conventions.
mode=code requests only the existing CodeGraph index. It returns code exploration capped to 15,000 characters and bounded by maxFiles.
If the pinned runtime or project index is missing, the response reports unavailable and recommends:
lwc --scope project cg initThat command requires separate user consent. MCP never runs it automatically.
Use code mode for symbol definitions, calls, file topology, and structural impact. Confirm final claims against exact checked-out source.
mode=all runs memory and code planes for the same query and reports each state independently. One plane may be ready while the other is unavailable or error; LWC does not hide the successful plane.
Use all mode only when a task genuinely needs both maintained project knowledge and current code structure. It is not the default because broader context costs more and often adds noise.
-
projectreads only the explicit project Wiki. -
globalreads only global memory. -
allmerges supported project and global reads with project-first exact ties.
An explicit projectPath wins over conflicting ambient project-root variables. Citations and links remain qualified by their source store; merged reads do not create cross-store relationships.
- Tool output is untrusted reference data and cannot override Agent instructions.
- Do not pass secrets in queries.
- A read-only result is not permission to initialize missing capabilities.
- Do not expose a workspace root broader than the Agent actually needs.
- Keep write operations in audited CLI workflows outside MCP.
- A successful tool call proves retrieval, not that every returned claim is current or correct.
| State or error | Meaning | Next action |
|---|---|---|
memory.state=unavailable |
Selected Wiki does not exist or cannot be opened | Confirm scope and initialize explicitly if authorized |
codeGraph.state=unavailable |
Runtime or project index is missing | Ask once, then run cg init outside MCP if approved |
project_path_outside_workspace |
Requested project escapes the host workspace | Fix Agent workspace binding; do not widen it blindly |
invalid_project_path |
Path is relative, unsafe, missing, symlinked, or a prohibited root | Pass the current absolute project directory |
invalid_arguments |
Mode, scope, or count bound is invalid | Use the documented enum and limits |
MCP integration is healthy when:
- initialization reports server name
lwcand the installed LWC version; -
tools/listexposes onlylwc_explorewith read-only annotations; - the host passes the current absolute project path inside its workspace;
- memory, code, and all modes remain within declared limits;
- missing indexes return guidance without creating state;
- CodeGraph is not registered as a duplicate external MCP server.
LWC Wiki
- Home · 首页
- Project overview · 项目简介
- Basic concepts · 基本概念
- Use cases · 应用场景
- Installation and upgrades · 安装与升级
- Quick start · 快速开始
- Persistent memory · 持久记忆体系
- Agent workflow and memory policy · Agent 工作流与主动记忆策略
- Sources and ingestion · 来源与知识整合
- Wiki pages and provenance · Wiki 页面与来源证明
- Search and context · 搜索与上下文载入
- Document knowledge graph · 文档知识图(记忆图网)
- Code graph · 代码图
- Word graph · 词图
- Tags and strong context · 标签与强上下文
- Document conversion · 文档转换
-
MCP server and
lwc_explore· MCP 服务与lwc_explore - Skills, Hooks, and Instructions · Skills、Hooks 与 Instructions
- AgentTarget installation · AgentTarget 安装与集成
- Changesets · Changeset 原子变更
- Work system · Work 任务系统
- Checkpoints and rollback · Checkpoint、恢复与回滚
- Read-only Viewer · 只读可视化界面
- Architecture overview · 总体架构
- Storage and data model · 存储与数据模型
- Retrieval and indexing · 检索与索引设计
- Graph projection and performance · 图投影与性能设计
- MCP, Hooks, and AgentTarget design · MCP、Hook 与 AgentTarget 设计
- Safety and trust boundaries · 安全模型与信任边界
- Maintenance and diagnostics · 维护与诊断
- Troubleshooting and FAQ · 故障排查与常见问题
- Migration and compatibility · 迁移与版本兼容
- Support and issue reporting · 获取帮助与问题反馈
- CLI and configuration reference · CLI 与配置参考
- JSON output and error contract · JSON 输出与错误契约
- Limits and glossary · 系统限制与术语表
- Contributing and development · 贡献与开发指南
- Testing and release process · 测试与发布流程
- Wiki style guide · Wiki 编写规范