You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .archcore/cli/mcp-token-optimization.idea.md
+29-11Lines changed: 29 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,23 @@ status: draft
7
7
8
8
Reduce token consumption of the MCP server by deduplicating tool descriptions, trimming redundant response fields, and consolidating disambiguation rules — without sacrificing document classification accuracy.
**Partially shipped** in commit `05d1af3 fix: safe token optimizations in MCP tools` (2026-05-12). The "safe" subset — changes that do not alter the response contract or risk type-selection accuracy — has landed. The riskier items (response-shape changes and full system-prompt consolidation) remain open and are tracked below.
15
+
16
+
### Shipped (safe)
17
+
18
+
-**Compressed `create_document` description** (partial Item 1). The 18 document types are still enumerated in the tool description, but each entry is now one or two lines instead of a full multi-line section list. Section detail is delegated to the auto-generated template. The `tags` and `content` parameter descriptions were also tightened, with longer reference text pushed to server instructions. Net effect: roughly half the tokens of the original create_document schema, without removing type guidance.
19
+
-**`nearby_documents` cap** (Item 5). `populateNearbyDocuments` in `internal/mcp/tools/create_document.go` now sorts results alphabetically and caps at `maxNearbyDocuments = 5`. Bounds the response size in large directories.
20
+
21
+
### Not shipped (deferred)
22
+
23
+
-**Item 1 (full)** — Removing the type list from `create_document` entirely and pointing to system instructions. The compressed version was chosen instead because tool-schema-weighted models still benefit from in-schema type names. Full deduplication remains a candidate if A/B testing shows the compressed list is also expendable.
24
+
-**Item 2 — Remove `filename` + `slug` from `list_documents` response.** Both fields are still in `LocalDocument` (`internal/mcp/tools/common.go`). Mechanically derivable from `path`. ~430 tokens / 50 docs.
25
+
-**Item 3 — Strip frontmatter from `content` in `get_document` response.** Still returned verbatim. Contract change — needs a migration plan (or a `raw` opt-in parameter) before shipping. ~10–14 tokens/call.
26
+
-**Item 4 — Consolidate requirements tracks + layers + type selection in `mcpServerInstructions`.**`internal/mcp/server.go` was not touched in `05d1af3`. ~150–200 tokens.
The tool description re-lists all 18 types with required sections (~700 tokens) that already exist in system instructions. Replace with a reference: "See system instructions for required sections per type."
The tool description re-lists all 18 types with required sections (~700 tokens) that already exist in system instructions. The compressed shipped version keeps a one-line summary per type; a future change could replace with a single reference: "See system instructions for required sections per type."
52
70
53
-
### 2. Remove `filename` + `slug` from `list_documents` response (~430 tokens per 50 docs)
71
+
### 2. Remove `filename` + `slug` from `list_documents` response (~430 tokens per 50 docs) — *open*
54
72
Both are mechanically derivable from `path`. Strip from JSON response.
55
73
56
-
### 3. Strip frontmatter from `content` in `get_document` response (~10–14 tokens/call)
74
+
### 3. Strip frontmatter from `content` in `get_document` response (~10–14 tokens/call) — *open*
57
75
`title` and `status` are already decoded as separate JSON fields. The raw frontmatter inside `content` is redundant.
Three overlapping blocks cover similar disambiguation ground. Merge into a single compact reference table.
61
79
62
-
### 5. Cap `nearby_documents` in `create_document` response (up to ~286 tokens saved)
63
-
In directories with 20+ documents, the hint array grows unbounded. Cap at 5 entries.
80
+
### 5. Cap `nearby_documents` in `create_document` response (up to ~286 tokens saved) — *shipped in `05d1af3`*
81
+
Capped at 5 entries, sorted alphabetically.
64
82
65
83
## Risks and Constraints
66
84
67
-
-**Deduplication risk**: Some LLMs weight tool-level descriptions higher than system instructions. Removing type info from `create_document` may reduce accuracy for models that prioritize tool schemas over system prompt. Needs A/B testing.
85
+
-**Deduplication risk**: Some LLMs weight tool-level descriptions higher than system instructions. Removing type info from `create_document` may reduce accuracy for models that prioritize tool schemas over system prompt. Needs A/B testing. The compressed form shipped in `05d1af3` is a hedge against this risk.
68
86
-**Stripping frontmatter from get_document**: Changes the contract — agents that parse `content` expecting frontmatter will break. Requires migration path or a `raw` parameter.
69
87
-**Consolidating disambiguation rules**: The current verbose format is optimized for LLM comprehension. A compact table may reduce readability for the model. Test with edge cases (brs vs brd, strs vs urd).
70
-
-**Session-start context scales with repo size**: The document list and relations summary grow linearly. This analysis covers the fixed prompt; the scaling overhead is a separate concern.
88
+
-**Session-start context scales with repo size**: The document list and relations summary grow linearly. This analysis covers the fixed prompt; the scaling overhead is a separate concern.
Copy file name to clipboardExpand all lines: .archcore/integrations/agent-hooks-integration.guide.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -218,6 +218,29 @@ Cline stores MCP config in VS Code `globalStorage`, not in project files. To add
218
218
1. Open Cline MCP settings in VS Code
219
219
2. Add an MCP server with command `archcore` and args `["mcp"]`
220
220
221
+
## Pointing the MCP Server at a Specific Project Root
222
+
223
+
By default `archcore mcp` serves documents from the current working directory. Some editor integrations launch the binary from a directory that isn't the workspace root (e.g. a desktop app's install dir, or a Cline globalStorage profile). In those cases the server may see an empty/wrong project.
When archcore reads a config file that contains invalid JSON, it creates a `.bak` backup before proceeding with a fresh config. This prevents data loss while keeping the installation non-blocking.
@@ -233,6 +256,14 @@ See [Backup Invalid Configs](backup-invalid-configs.adr.md) for the full decisio
233
256
- The **MCP server** (`archcore mcp`) starts fine without `.archcore/` — it exposes `init_project` so the agent can bootstrap the directory in-session. If the agent sees an empty `list_documents` result and wants to create documents, it should call `init_project` first.
234
257
-**Hooks** and the `archcore hooks/mcp install` commands still require an initialized project. Run `archcore init` first, or ask the agent to call `init_project`.
235
258
259
+
### MCP server is serving the wrong directory
260
+
261
+
Symptoms: `list_documents` returns an empty array even though the workspace clearly has `.archcore/` documents, or `init_project` would create the directory in an unexpected location.
262
+
263
+
Cause: the agent launched `archcore mcp` from a working directory that isn't your workspace.
264
+
265
+
Fix: pass `--project` explicitly in the agent's MCP config, or set `ARCHCORE_PROJECT_ROOT` in the agent's environment. See **Pointing the MCP Server at a Specific Project Root** above.
266
+
236
267
### Agent not detected
237
268
238
269
Check that the agent's marker directory exists in your project root. You can also target a specific agent with `--agent`:
Copy file name to clipboardExpand all lines: .archcore/mcp/mcp-server-starts-without-archcore-dir.adr.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Two user flows were affected:
16
16
17
17
## Decision
18
18
19
-
1.**`archcore mcp` starts unconditionally.** The `.archcore/` existence check in `cmd/mcp.go` is removed. The server always boots on stdio and prints a hint in the startup banner when the directory is missing.
19
+
1.**`archcore mcp` starts unconditionally for the default (cwd) project root.** The `.archcore/` existence check in `cmd/mcp.go` is removed. The server always boots on stdio and prints a hint in the startup banner when the directory is missing.
20
20
2.**Add an `init_project` MCP tool** (`internal/mcp/tools/init_project.go`). It creates `.archcore/` and writes `settings.json` from within the MCP server itself. It accepts `language`, `sync_mode`, and `archcore_url` and is idempotent — calling it on an already-initialized project returns the existing settings without overwriting them.
21
21
3.**Server instructions document the bootstrap flow.** The system prompt embedded in `internal/mcp/server.go` (`mcpServerInstructions`) explicitly tells the agent: "if `list_documents` returns empty AND the user wants to create documents, call `init_project` once, then proceed."
22
22
4.**Other tools continue to assume `.archcore/` exists.**`create_document`, `list_documents`, `update_document`, etc. are not changed to auto-init. The only tool safe to call on an uninitialized project is `init_project`.
@@ -40,3 +40,12 @@ Negative / constraints:
40
40
- The MCP server now has a "degraded" mode (running, but most tools will fail). The startup banner's hint compensates, but agents that ignore system prompts may attempt `create_document` before `init_project` and see confusing errors. Mitigated by the explicit instruction block in `mcpServerInstructions`.
41
41
-`init_project` must stay idempotent. A regression that clobbers existing `settings.json` on the second call would destroy user configuration. Covered by `TestHandleInitProject_Idempotent`.
42
42
- Any future MCP tool that *also* safely works on an uninitialized project must be documented in the server instructions alongside `init_project`. Today that list is just `init_project`.
43
+
44
+
### Scope of the "unconditional start" property
45
+
46
+
The unconditional-start guarantee applies to the **default project root** (cwd) and to the case where `.archcore/` is missing inside an existing project directory. It does **not** override the project-root resolution layer:
47
+
48
+
- When `--project <path>` is passed to `archcore mcp`, or `ARCHCORE_PROJECT_ROOT` is set, the resolver (`cmd/mcp_root.go`) requires the path to exist and to be a directory. A missing or non-directory path causes the command to exit before the server starts.
49
+
- This is intentional: if the user explicitly names a project root, silently falling back to cwd would be more surprising than failing fast. `.archcore/`*inside* the resolved root may still be absent — the server still starts in that case and exposes `init_project`.
50
+
51
+
In short: the server tolerates a missing `.archcore/`, but does not tolerate a missing project directory the user explicitly named.
- GitHub Release page shows 6 archives (4 `.tar.gz`for darwin/linux amd64+arm64, 2 `.zip` for windows amd64+arm64) plus`checksums.txt`
60
63
-`archcore --version` on installed binary shows correct version and commit
61
-
- Install script succeeds on a clean machine
64
+
- Install script succeeds on a clean macOS/Linux machine
65
+
-`install.ps1` succeeds on a clean Windows machine
66
+
67
+
See [Release Infrastructure Overview](release-infrastructure.doc.md) for the full build matrix, artifact naming, and update paths.
62
68
63
69
## Common Issues
64
70
65
71
-**Workflow fails at test step** — Fix the tests on `main`, delete the tag (`git push origin :v1.0.0 && git tag -d v1.0.0`), then re-tag after fixing.
66
72
-**GoReleaser fails** — Check `.goreleaser.yaml` syntax. Run `goreleaser check` locally if available.
67
73
-**Wrong commit tagged** — Delete the remote tag, re-tag the correct commit, and push again.
68
-
-**install.sh can't find the release** — Ensure the tag follows the `v*` pattern (e.g. `v1.0.0`, not `1.0.0`).
74
+
-**install.sh / install.ps1 can't find the release** — Ensure the tag follows the `v*` pattern (e.g. `v1.0.0`, not `1.0.0`).
75
+
-**Windows zips missing from release** — Confirm `.goreleaser.yaml``format_overrides` still maps `windows` to `zip`; otherwise GoReleaser will fall back to `.tar.gz` and `install.ps1` won't find the expected archives.
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -301,6 +301,8 @@ Archcore does not require a hosted service. The CLI runs a local stdio MCP serve
301
301
archcore mcp
302
302
```
303
303
304
+
By default `archcore mcp` serves documents from the current directory. Pass `--project /path/to/repo` (or set `ARCHCORE_PROJECT_ROOT`) to point it elsewhere — useful when the server is launched from a directory that isn't your workspace (for example, by an editor integration).
fmt.Fprintln(os.Stderr, display.Dim.Render(" MCP server running on stdio (uninitialized project — only init_project tool is useful until the agent initializes .archcore/)..."))
31
33
} else {
32
34
fmt.Fprintln(os.Stderr, display.Dim.Render(" MCP server running on stdio..."))
0 commit comments