@dimassetoid/septum-mcp 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -28
- package/package.json +4 -4
- package/src/cli/commands/check.ts +27 -16
- package/src/cli/commands/hook.ts +38 -101
- package/src/cli/commands/init.ts +26 -9
- package/src/cli/commands/sync.ts +4 -6
- package/src/cli/hook-payload.ts +43 -0
- package/src/cli/index.ts +9 -52
- package/src/cli/scaffold/harness-config.ts +48 -8
- package/src/cli/templates/hooks.ts +49 -14
- package/src/cli/templates/rules.ts +34 -49
- package/src/cli/templates/skill.ts +39 -35
- package/src/core/boundary/evaluator.ts +67 -83
- package/src/core/boundary/staged-auditor.ts +102 -40
- package/src/core/config/domain-ownership.ts +45 -0
- package/src/core/config/loader.ts +81 -29
- package/src/core/config/schema.ts +0 -10
- package/src/core/database/repositories/dependency.repository.ts +169 -148
- package/src/core/database/repositories/domain.repository.ts +46 -3
- package/src/core/database/repositories/symbol.repository.ts +226 -87
- package/src/core/database/repository.ts +73 -18
- package/src/core/database/schema.ts +2 -33
- package/src/core/discovery/navigation.ts +105 -0
- package/src/core/discovery/topology-detector.ts +60 -2
- package/src/core/ingestion/pipeline.ts +96 -129
- package/src/core/parser/behavioral-analyzer.ts +26 -22
- package/src/core/parser/boundary-tracker.ts +15 -0
- package/src/core/parser/extractors/base.ts +7 -3
- package/src/core/parser/extractors/csharp.ts +7 -3
- package/src/core/parser/extractors/django-semantic.ts +4 -36
- package/src/core/parser/extractors/elysia-semantic.ts +3 -24
- package/src/core/parser/extractors/express-semantic.ts +3 -18
- package/src/core/parser/extractors/fastapi-semantic.ts +19 -53
- package/src/core/parser/extractors/fastify-semantic.ts +3 -18
- package/src/core/parser/extractors/flask-semantic.ts +22 -55
- package/src/core/parser/extractors/go-semantic.ts +92 -33
- package/src/core/parser/extractors/hono-semantic.ts +3 -24
- package/src/core/parser/extractors/java.ts +5 -3
- package/src/core/parser/extractors/laravel-semantic.ts +44 -16
- package/src/core/parser/extractors/mcp-cli-semantic.ts +6 -7
- package/src/core/parser/extractors/nestjs-semantic.ts +3 -19
- package/src/core/parser/extractors/php.ts +16 -0
- package/src/core/parser/extractors/python.ts +9 -4
- package/src/core/parser/extractors/registry.ts +26 -5
- package/src/core/parser/extractors/ruby.ts +8 -5
- package/src/core/parser/extractors/rust.ts +31 -13
- package/src/core/parser/extractors/semantic-extractor.interface.ts +3 -1
- package/src/core/parser/extractors/symfony-semantic.ts +4 -37
- package/src/core/parser/extractors/typescript.ts +14 -1
- package/src/core/parser/implementation-fingerprint.ts +97 -0
- package/src/core/parser/language-capabilities.ts +23 -7
- package/src/core/parser/schema/providers/laravel-migration-provider.ts +73 -50
- package/src/core/parser/schema/schema-provider-registry.ts +1 -3
- package/src/core/parser/schema/schema-provider.interface.ts +2 -1
- package/src/core/parser/semantic-revision.ts +3 -0
- package/src/core/parser/static-string.ts +51 -0
- package/src/core/resolver/call-graph-tracer.ts +337 -28
- package/src/core/resolver/import-resolver.ts +107 -179
- package/src/core/resolver/interpretation-inputs.ts +7 -0
- package/src/core/resolver/languages/go.ts +103 -0
- package/src/core/resolver/languages/managed.ts +200 -0
- package/src/core/resolver/languages/python.ts +115 -0
- package/src/core/resolver/languages/ruby.ts +40 -0
- package/src/core/resolver/languages/rust.ts +127 -0
- package/src/core/resolver/languages/shared.ts +71 -0
- package/src/core/resolver/module-resolver.ts +8 -4
- package/src/core/resolver/slice-catalog.ts +79 -0
- package/src/core/resolver/slice-format.ts +9 -0
- package/src/core/resolver/symbol-impact.ts +381 -0
- package/src/core/resolver/vertical-slice-tracer.ts +93 -115
- package/src/core/resources/ignore.ts +22 -1
- package/src/core/resources/source-files.ts +143 -20
- package/src/core/resources/source-inventory.ts +55 -0
- package/src/core/retrieval/context-page.ts +109 -0
- package/src/core/retrieval/context.ts +320 -0
- package/src/core/retrieval/resolution-warnings.ts +21 -0
- package/src/core/retrieval/symbol-evidence.ts +97 -0
- package/src/core/retrieval/typescript-references.ts +262 -0
- package/src/core/telemetry/telemetry.ts +54 -9
- package/src/index.ts +0 -3
- package/src/mcp/schemas.ts +61 -420
- package/src/mcp/server.ts +116 -290
- package/src/mcp/tools/boundary.ts +2 -2
- package/src/mcp/tools/check-boundary.ts +55 -60
- package/src/mcp/tools/get-domain-catalog.ts +32 -219
- package/src/mcp/tools/get-symbol-impact.ts +45 -5
- package/src/mcp/tools/get-symbol.ts +227 -3
- package/src/mcp/tools/locate-symbol.ts +54 -14
- package/src/mcp/tools/{domain.ts → map.ts} +4 -18
- package/src/mcp/tools/register-domain.ts +41 -3
- package/src/mcp/tools/symbol.ts +23 -21
- package/src/mcp/tools/trace-vertical-slice.ts +36 -10
- package/src/mcp/workspace-manager.ts +15 -4
- package/src/mcp/workspace-watcher.ts +8 -8
- package/src/types/index.ts +35 -53
- package/src/cli/commands/topology.ts +0 -161
- package/src/core/database/repositories/environment.repository.ts +0 -207
- package/src/core/parser/schema/providers/prisma-schema-provider.ts +0 -90
- package/src/core/session/session-manager.ts +0 -107
- package/src/core/topology/environment-detector.ts +0 -973
- package/src/core/topology/types.ts +0 -83
- package/src/mcp/tools/feature.ts +0 -67
- package/src/mcp/tools/get-environment-topology.ts +0 -138
- package/src/mcp/tools/get-feature-context.ts +0 -224
- package/src/mcp/tools/get-symbol-hotspots.ts +0 -54
- package/src/mcp/tools/register-feature.ts +0 -110
package/src/mcp/server.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildUnindexedCatalog } from "./tools/get-domain-catalog.ts";
|
|
1
2
|
import { WorkspaceManager, resolveServerWorkspace, isWorkspaceInitialized, type WorkspaceLease } from "./workspace-manager.ts";
|
|
2
3
|
import { RESOURCE_LIMITS } from "../core/resources/limits.ts";
|
|
3
4
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
@@ -7,31 +8,18 @@ import {
|
|
|
7
8
|
ListToolsRequestSchema,
|
|
8
9
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
9
10
|
import { ConfigLoader } from "../core/config/loader.ts";
|
|
10
|
-
import { SessionManager } from "../core/session/session-manager.ts";
|
|
11
11
|
import { SeptumTelemetry } from "../core/telemetry/telemetry.ts";
|
|
12
|
-
import {
|
|
12
|
+
import { handleMapTool } from "./tools/map.ts";
|
|
13
13
|
import { handleSymbolTool } from "./tools/symbol.ts";
|
|
14
14
|
import { handleSliceTool } from "./tools/slice.ts";
|
|
15
15
|
import { handleBoundaryTool } from "./tools/boundary.ts";
|
|
16
|
-
import {
|
|
16
|
+
import { DomainRootConflictError } from "../core/config/domain-ownership.ts";
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
|
-
|
|
20
|
-
SymbolToolSchema,
|
|
21
|
-
SliceToolSchema,
|
|
22
|
-
BoundaryToolSchema,
|
|
23
|
-
FeatureToolSchema,
|
|
19
|
+
parseToolRequest,
|
|
24
20
|
} from "./schemas.ts";
|
|
25
21
|
import { SEPTUM_VERSION, checkRuntimeVersion } from "../utils/version-check.ts";
|
|
26
22
|
|
|
27
|
-
const TOOL_SCHEMAS = {
|
|
28
|
-
septum_domain: DomainToolSchema,
|
|
29
|
-
septum_symbol: SymbolToolSchema,
|
|
30
|
-
septum_slice: SliceToolSchema,
|
|
31
|
-
septum_boundary: BoundaryToolSchema,
|
|
32
|
-
septum_feature: FeatureToolSchema,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
23
|
export function extractPathHint(args: unknown): string | undefined {
|
|
36
24
|
if (!args) return undefined;
|
|
37
25
|
|
|
@@ -111,8 +99,17 @@ function countLines(text: string): number {
|
|
|
111
99
|
return count;
|
|
112
100
|
}
|
|
113
101
|
|
|
102
|
+
export const SEPTUM_SERVER_INSTRUCTIONS = `Septum indexes supported declarations, imports, domain policies and static entrypoints.
|
|
103
|
+
Guidelines for AI Coding Agents:
|
|
104
|
+
1. CONTEXT: Call septum_symbol(action: 'context') for declaration source and supporting references. Deep TypeScript context uses budget_bytes and continuation; source inspection uses line limits. Read freshness, diagnostics and omissions, then inspect further source when needed.
|
|
105
|
+
2. NAVIGATION: Call septum_map(action: 'catalog') for domain/file locations, import relationships, static entrypoints and index health.
|
|
106
|
+
3. CONSUMERS: Before changing public contracts, inspect septum_symbol(action: 'impact') and relevant consumers. Import dependents and caller hints are incomplete static evidence; verify affected application behavior.
|
|
107
|
+
4. ENTRYPOINTS: Call septum_slice(query: '<route|handler>') for catalog matches and related nodes. Matching confidence does not establish runtime reachability or execution order.
|
|
108
|
+
5. BOUNDARIES: Call septum_boundary(scope: 'file', file_path: '...', proposed_imports: [...]) for candidate imports, or scope: 'all'/'domain'/'staged' for those audit scopes. Proposal approval does not audit existing imports. Unknown is not approval; approved describes only the evaluated static scope.`;
|
|
109
|
+
|
|
114
110
|
export async function runMCPServer(): Promise<void> {
|
|
115
111
|
const manager = new WorkspaceManager();
|
|
112
|
+
void checkRuntimeVersion().catch(() => {});
|
|
116
113
|
|
|
117
114
|
const server = new Server(
|
|
118
115
|
{
|
|
@@ -123,6 +120,7 @@ export async function runMCPServer(): Promise<void> {
|
|
|
123
120
|
capabilities: {
|
|
124
121
|
tools: {},
|
|
125
122
|
},
|
|
123
|
+
instructions: SEPTUM_SERVER_INSTRUCTIONS,
|
|
126
124
|
}
|
|
127
125
|
);
|
|
128
126
|
|
|
@@ -130,17 +128,17 @@ export async function runMCPServer(): Promise<void> {
|
|
|
130
128
|
return {
|
|
131
129
|
tools: [
|
|
132
130
|
{
|
|
133
|
-
name: "
|
|
131
|
+
name: "septum_map",
|
|
134
132
|
description:
|
|
135
|
-
"
|
|
133
|
+
"Navigate architecture: workspace domains and cross-domain import adjacency, domain/file neighborhoods, static entrypoints and coverage. Output schema navigation/v1. Signatures, member lists and source belong to septum_symbol; full expands navigation only. Use file_filter to focus, include_evidence for one file's import details, or septum_slice for static handler relationships. Example: {action:'catalog',domain:'mcp'}.",
|
|
136
134
|
inputSchema: {
|
|
137
135
|
type: "object",
|
|
138
136
|
properties: {
|
|
139
137
|
action: {
|
|
140
138
|
type: "string",
|
|
141
|
-
enum: ["catalog", "register"
|
|
139
|
+
enum: ["catalog", "register"],
|
|
142
140
|
default: "catalog",
|
|
143
|
-
description: "Sub-operation to execute: 'catalog' (inspect domain/macro map)
|
|
141
|
+
description: "Sub-operation to execute: 'catalog' (inspect domain/macro map) or 'register' (dynamically register bounded-context domain).",
|
|
144
142
|
},
|
|
145
143
|
domain: {
|
|
146
144
|
type: "string",
|
|
@@ -150,7 +148,7 @@ export async function runMCPServer(): Promise<void> {
|
|
|
150
148
|
type: "string",
|
|
151
149
|
enum: ["compact", "full"],
|
|
152
150
|
default: "compact",
|
|
153
|
-
description: "
|
|
151
|
+
description: "Navigation extent: compact selects up to 40 files, full up to 100. Neither includes signatures or source; use septum_symbol for declaration inspection.",
|
|
154
152
|
},
|
|
155
153
|
archetype_filter: {
|
|
156
154
|
type: "string",
|
|
@@ -160,6 +158,10 @@ export async function runMCPServer(): Promise<void> {
|
|
|
160
158
|
type: "string",
|
|
161
159
|
description: "Optional substring filter to inspect specific file(s) within the domain.",
|
|
162
160
|
},
|
|
161
|
+
file_offset: { type: "integer", minimum: 0, description: "Start of the catalog file page; copy next_file_offset from pagination." },
|
|
162
|
+
file_limit: { type: "integer", minimum: 1, maximum: 100, description: "Optional navigation selection limit. Small scopes return together; pagination appears only when files remain." },
|
|
163
|
+
include_evidence: { type: "boolean", description: "Opt in to up to 20 raw import-evidence records; requires file_filter matching exactly one file." },
|
|
164
|
+
include_capabilities: { type: "boolean", description: "Opt in to language/parser capabilities; omitted from navigation by default." },
|
|
163
165
|
root: {
|
|
164
166
|
type: "string",
|
|
165
167
|
description: "Root directory path for domain registration (action='register').",
|
|
@@ -187,36 +189,6 @@ export async function runMCPServer(): Promise<void> {
|
|
|
187
189
|
default: false,
|
|
188
190
|
description: "Whether to immediately run AST ingestion on domain files upon registration.",
|
|
189
191
|
},
|
|
190
|
-
resolve: {
|
|
191
|
-
type: "object",
|
|
192
|
-
properties: {
|
|
193
|
-
layer: {
|
|
194
|
-
type: "string",
|
|
195
|
-
enum: ["edge", "gateway", "host", "runtime", "storage", "telemetry"],
|
|
196
|
-
},
|
|
197
|
-
platform: { type: "string" },
|
|
198
|
-
constraints: { type: "array", items: { type: "string" } },
|
|
199
|
-
},
|
|
200
|
-
description: "Record and verify infrastructure layer in SQLite SSOT (action='topology').",
|
|
201
|
-
},
|
|
202
|
-
resolve_node: {
|
|
203
|
-
type: "object",
|
|
204
|
-
properties: {
|
|
205
|
-
id: { type: "string" },
|
|
206
|
-
layer: { type: "string", enum: ["edge", "gateway", "host", "runtime", "storage", "telemetry"] },
|
|
207
|
-
name: { type: "string" },
|
|
208
|
-
platform: { type: "string" },
|
|
209
|
-
domain_or_ip: { type: "string" },
|
|
210
|
-
role: { type: "string" },
|
|
211
|
-
connected_to: { type: "array", items: { type: "string" } },
|
|
212
|
-
constraints: { type: "array", items: { type: "string" } },
|
|
213
|
-
},
|
|
214
|
-
description: "Record distributed topology node in SQLite SSOT (action='topology').",
|
|
215
|
-
},
|
|
216
|
-
refresh: {
|
|
217
|
-
type: "boolean",
|
|
218
|
-
description: "Force re-detection from codebase files, ignoring cached status (action='topology').",
|
|
219
|
-
},
|
|
220
192
|
workspace_path: {
|
|
221
193
|
type: "string",
|
|
222
194
|
description: "Explicit workspace root path. Specifies the target project root in multi-root environments.",
|
|
@@ -228,19 +200,19 @@ export async function runMCPServer(): Promise<void> {
|
|
|
228
200
|
{
|
|
229
201
|
name: "septum_symbol",
|
|
230
202
|
description:
|
|
231
|
-
"
|
|
203
|
+
"Locate indexed declarations, retrieve source/contracts, or inspect potential consumers. action='context' (alias 'inspect') selects deep TypeScript references or bounded source inspection; read mode, freshness, diagnostics and omissions. action='impact' separates import dependents from supported static call sites and inferred caller hints; the caller set is incomplete. Use septum_map for domain/file navigation and septum_slice for static entrypoint context. Example: {action:'context',query:'handleOrder',file_path:'src/orders.ts'}.",
|
|
232
204
|
inputSchema: {
|
|
233
205
|
type: "object",
|
|
234
206
|
properties: {
|
|
235
207
|
action: {
|
|
236
208
|
type: "string",
|
|
237
|
-
enum: ["locate", "
|
|
209
|
+
enum: ["locate", "context", "inspect", "impact"],
|
|
238
210
|
default: "locate",
|
|
239
|
-
description: "
|
|
211
|
+
description: "'locate' finds declarations; 'context' (or 'inspect') retrieves declaration source along with local/import-bound supporting declarations for TypeScript within budget_bytes, or bounded source for polyglot files; 'impact' reports static caller hints. Example: {action:'context',query:'submit',file_path:'src/submit.ts'}.",
|
|
240
212
|
},
|
|
241
213
|
query: {
|
|
242
214
|
type: "string",
|
|
243
|
-
description: "Symbol name, call syntax (e.g. 'OrderController::cancelOrder'), or search query
|
|
215
|
+
description: "Symbol name, call syntax (e.g. 'OrderController::cancelOrder'), or search query.",
|
|
244
216
|
},
|
|
245
217
|
domain: {
|
|
246
218
|
type: "string",
|
|
@@ -252,7 +224,7 @@ export async function runMCPServer(): Promise<void> {
|
|
|
252
224
|
},
|
|
253
225
|
symbol_ref: {
|
|
254
226
|
type: "object",
|
|
255
|
-
description: "Declaration reference returned by locate
|
|
227
|
+
description: "Declaration reference returned by locate or catalog. Stale indexed fingerprints are refused.",
|
|
256
228
|
properties: {
|
|
257
229
|
file_path: { type: "string", minLength: 1 },
|
|
258
230
|
language: { type: "string", minLength: 1 },
|
|
@@ -269,47 +241,44 @@ export async function runMCPServer(): Promise<void> {
|
|
|
269
241
|
},
|
|
270
242
|
include_source: {
|
|
271
243
|
type: "boolean",
|
|
272
|
-
|
|
273
|
-
description: "For action='inspect', include a bounded source slice only when the indexed file fingerprint still matches disk.",
|
|
244
|
+
description: "Explicit true selects bounded source; explicit false selects declaration details without source. Omit for deep TypeScript context or default polyglot source. Source hashes must match disk.",
|
|
274
245
|
},
|
|
275
246
|
source_start_line: {
|
|
276
247
|
type: "number",
|
|
277
248
|
minimum: 1,
|
|
278
|
-
description: "First line to return within the selected symbol range
|
|
249
|
+
description: "First line to return within the selected symbol range.",
|
|
279
250
|
},
|
|
280
251
|
source_line_limit: {
|
|
281
252
|
type: "number",
|
|
282
253
|
minimum: 1,
|
|
283
254
|
maximum: 200,
|
|
284
|
-
|
|
285
|
-
|
|
255
|
+
description: "Select bounded source inspection with this line limit (capped at 200). Bounded mode uses 120 lines when omitted.",
|
|
256
|
+
},
|
|
257
|
+
context_mode: {
|
|
258
|
+
type: "string", enum: ["deep", "source"],
|
|
259
|
+
description: "Explicit context mode. deep selects referenced TypeScript declarations; source selects bounded source inspection. Omit for legacy automatic selection.",
|
|
286
260
|
},
|
|
287
261
|
include_dependencies: {
|
|
288
262
|
type: "boolean",
|
|
289
263
|
default: true,
|
|
290
|
-
description: "Whether to include injected dependencies and outbound calls
|
|
291
|
-
},
|
|
292
|
-
min_lines: {
|
|
293
|
-
type: "number",
|
|
294
|
-
description: "Minimum physical lines of code threshold (action='hotspots', default: 30).",
|
|
264
|
+
description: "Whether to include injected dependencies and outbound calls.",
|
|
295
265
|
},
|
|
296
|
-
|
|
297
|
-
type: "
|
|
298
|
-
|
|
266
|
+
budget_bytes: {
|
|
267
|
+
type: "integer",
|
|
268
|
+
minimum: 2048,
|
|
269
|
+
maximum: 2097152,
|
|
270
|
+
default: 16384,
|
|
271
|
+
description: "For deep TypeScript context (including inspect alias): maximum UTF-8 bytes of the serialized MCP tool result, including evidence and continuation. Do not combine with bounded source options.",
|
|
299
272
|
},
|
|
300
|
-
|
|
273
|
+
continuation: {
|
|
301
274
|
type: "string",
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
type: "string",
|
|
306
|
-
enum: ["risk_score", "line_count", "lines", "nesting"],
|
|
307
|
-
default: "risk_score",
|
|
308
|
-
description: "Sorting criteria for hotspots (action='hotspots').",
|
|
275
|
+
minLength: 1,
|
|
276
|
+
maxLength: 4096,
|
|
277
|
+
description: "For action='context': copy the previous page token with the same target and budget.",
|
|
309
278
|
},
|
|
310
279
|
limit: {
|
|
311
280
|
type: "number",
|
|
312
|
-
description: "Maximum results to return (default: 10
|
|
281
|
+
description: "Maximum results to return for locate (default: 10).",
|
|
313
282
|
},
|
|
314
283
|
workspace_path: {
|
|
315
284
|
type: "string",
|
|
@@ -322,7 +291,7 @@ export async function runMCPServer(): Promise<void> {
|
|
|
322
291
|
{
|
|
323
292
|
name: "septum_slice",
|
|
324
293
|
description:
|
|
325
|
-
"
|
|
294
|
+
"Match a supported static entrypoint and inspect related nodes with relationship evidence and diagnostics. Supports cataloged routes, handlers, jobs, CLI commands and events; results do not establish runtime execution order or complete reachability. Use septum_symbol for declarations and septum_boundary for import policy. Example: {query:'POST /orders/{id}/pay',max_depth:5} or {query:'OrderController@pay'}.",
|
|
326
295
|
inputSchema: {
|
|
327
296
|
type: "object",
|
|
328
297
|
properties: {
|
|
@@ -330,6 +299,11 @@ export async function runMCPServer(): Promise<void> {
|
|
|
330
299
|
type: "string",
|
|
331
300
|
description: "Route URI (e.g. 'POST /orders/{id}/pay'), action (e.g. 'OrderController@pay'), or high-level task intent.",
|
|
332
301
|
},
|
|
302
|
+
controller_file: {
|
|
303
|
+
type: "string",
|
|
304
|
+
minLength: 1,
|
|
305
|
+
description: "Exact catalog controller/handler file copied from an ambiguity candidate. Filters target selection.",
|
|
306
|
+
},
|
|
333
307
|
max_depth: {
|
|
334
308
|
type: "number",
|
|
335
309
|
default: 5,
|
|
@@ -348,14 +322,15 @@ export async function runMCPServer(): Promise<void> {
|
|
|
348
322
|
{
|
|
349
323
|
name: "septum_boundary",
|
|
350
324
|
description:
|
|
351
|
-
"
|
|
325
|
+
"Architectural firewall: validate proposed or staged imports against domain boundaries and circular dependency constraints. When to use: (1) scope='file' with proposed_imports BEFORE writing new import statements, (2) scope='staged' BEFORE git commit to prevent cross-domain leaks, (3) scope='all' or 'domain' for codebase audits. When NOT to use: do NOT use to read source code or locate symbols. Status 'approved' confirms zero violations; 'rejected' requires refactoring. Example: {scope:'file',file_path:'src/order/service.ts',proposed_imports:['../billing/repo']}.",
|
|
352
326
|
inputSchema: {
|
|
353
327
|
type: "object",
|
|
354
328
|
properties: {
|
|
355
329
|
scope: {
|
|
356
330
|
type: "string",
|
|
357
331
|
enum: ["file", "staged", "all", "domain"],
|
|
358
|
-
|
|
332
|
+
default: "file",
|
|
333
|
+
description: "'file' evaluates proposed imports against domain policies; 'staged' audits git index changes; 'domain' checks a specific domain's violations; 'all' audits the entire workspace.",
|
|
359
334
|
},
|
|
360
335
|
file_path: {
|
|
361
336
|
type: "string",
|
|
@@ -364,7 +339,7 @@ export async function runMCPServer(): Promise<void> {
|
|
|
364
339
|
file_paths: {
|
|
365
340
|
type: "array",
|
|
366
341
|
items: { type: "string" },
|
|
367
|
-
description: "Non-empty list of file paths for batch proposed-import checks (scope='file' only).
|
|
342
|
+
description: "Non-empty list of file paths for batch proposed-import checks (scope='file' only).",
|
|
368
343
|
},
|
|
369
344
|
proposed_imports: {
|
|
370
345
|
type: "array",
|
|
@@ -373,67 +348,11 @@ export async function runMCPServer(): Promise<void> {
|
|
|
373
348
|
},
|
|
374
349
|
domain: {
|
|
375
350
|
type: "string",
|
|
376
|
-
description: "Registered domain name, required for scope='domain'; optional for staged/file checks.
|
|
377
|
-
},
|
|
378
|
-
feature_key: {
|
|
379
|
-
type: "string",
|
|
380
|
-
description: "Optional feature key to validate touchpoints against.",
|
|
381
|
-
},
|
|
382
|
-
workspace_path: {
|
|
383
|
-
type: "string",
|
|
384
|
-
description: "Explicit workspace root path. Specifies the target project root in multi-root environments.",
|
|
385
|
-
},
|
|
386
|
-
},
|
|
387
|
-
required: [],
|
|
388
|
-
},
|
|
389
|
-
},
|
|
390
|
-
{
|
|
391
|
-
name: "septum_feature",
|
|
392
|
-
description:
|
|
393
|
-
"Active Touchpoint & Scope Lock Engine: manages feature task context, touchpoint locks (.septum/session.json), and session release to enforce surgical blast-radius boundaries.",
|
|
394
|
-
inputSchema: {
|
|
395
|
-
type: "object",
|
|
396
|
-
properties: {
|
|
397
|
-
action: {
|
|
398
|
-
type: "string",
|
|
399
|
-
enum: ["get", "lock", "release"],
|
|
400
|
-
default: "get",
|
|
401
|
-
description: "Feature lifecycle action: 'get' (retrieve feature context), 'lock' (register feature & establish active session lease), or 'release' (release active session lock).",
|
|
351
|
+
description: "Registered domain name, required for scope='domain'; optional for staged/file checks.",
|
|
402
352
|
},
|
|
403
|
-
|
|
404
|
-
type: "string",
|
|
405
|
-
description: "Unique feature identifier (e.g. 'checkout_flow'). Symmetrically accepts 'feature'.",
|
|
406
|
-
},
|
|
407
|
-
domain: {
|
|
408
|
-
type: "string",
|
|
409
|
-
description: "Bounded-context domain for this feature (action='lock').",
|
|
410
|
-
},
|
|
411
|
-
description: {
|
|
412
|
-
type: "string",
|
|
413
|
-
description: "Scope and rationale for the feature (action='lock').",
|
|
414
|
-
},
|
|
415
|
-
allowed_touchpoints: {
|
|
416
|
-
type: "array",
|
|
417
|
-
items: { type: "string" },
|
|
418
|
-
description: "Permitted file paths or glob patterns (action='lock').",
|
|
419
|
-
},
|
|
420
|
-
reuse_symbols: {
|
|
421
|
-
type: "array",
|
|
422
|
-
items: { type: "string" },
|
|
423
|
-
description: "Mandatory reusable symbols (action='lock').",
|
|
424
|
-
},
|
|
425
|
-
input_contract: {
|
|
426
|
-
type: "object",
|
|
427
|
-
description: "Expected input payload / DTO schema (action='lock').",
|
|
428
|
-
},
|
|
429
|
-
output_contract: {
|
|
430
|
-
type: "object",
|
|
431
|
-
description: "Expected output response contract (action='lock').",
|
|
432
|
-
},
|
|
433
|
-
force: {
|
|
353
|
+
staged: {
|
|
434
354
|
type: "boolean",
|
|
435
|
-
|
|
436
|
-
description: "Force release session (action='release').",
|
|
355
|
+
description: "Convenience flag equivalent to scope='staged'.",
|
|
437
356
|
},
|
|
438
357
|
workspace_path: {
|
|
439
358
|
type: "string",
|
|
@@ -453,11 +372,10 @@ export async function runMCPServer(): Promise<void> {
|
|
|
453
372
|
let lease: WorkspaceLease | undefined;
|
|
454
373
|
try {
|
|
455
374
|
extra?.signal?.throwIfAborted();
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
const record = (validated.data ?? {}) as Record<string, any>;
|
|
375
|
+
let parsed;
|
|
376
|
+
try { parsed = parseToolRequest(name, args); }
|
|
377
|
+
catch (error) { throw new Error(`[Septum Validation Error] Invalid arguments for ${name}: ${error instanceof Error ? error.message : String(error)}`); }
|
|
378
|
+
const record = parsed.args;
|
|
461
379
|
const raw = (args ?? {}) as Record<string, any>;
|
|
462
380
|
const workspacePath = record.workspace_path ?? raw.workspace_path ?? raw.workspacePath ?? raw.workspace ?? raw.project_root ?? raw.projectRoot;
|
|
463
381
|
const knownRoots = manager.activeRoots;
|
|
@@ -473,34 +391,9 @@ export async function runMCPServer(): Promise<void> {
|
|
|
473
391
|
});
|
|
474
392
|
|
|
475
393
|
if (!isWorkspaceInitialized(root)) {
|
|
476
|
-
if (name === "
|
|
394
|
+
if (name === "septum_map" && (!("action" in record) || !record.action || record.action === "catalog")) {
|
|
477
395
|
const runtimeVersion = await checkRuntimeVersion();
|
|
478
|
-
|
|
479
|
-
"Panggil tool 'septum_domain(action: \"register\", name: \"core\", root: \"src\", ingest_now: true)' untuk mendaftarkan dan mengindeks domain utama secara otomatis, atau jalankan 'septum init' di terminal workspace.";
|
|
480
|
-
if (runtimeVersion.update_available) {
|
|
481
|
-
agentGuidance += ` Update available: v${runtimeVersion.server_version} -> v${runtimeVersion.latest_version}. Recommend running '${runtimeVersion.upgrade_command}' and reloading the MCP server if schema/features differ.`;
|
|
482
|
-
}
|
|
483
|
-
const diagnostic: Record<string, any> = {
|
|
484
|
-
status: "NOT_INDEXED",
|
|
485
|
-
total_domains: 0,
|
|
486
|
-
runtime_version: runtimeVersion,
|
|
487
|
-
message: `Workspace '${root}' belum diinisialisasi dengan Septum. Jalankan 'septum init' terlebih dahulu di terminal workspace.`,
|
|
488
|
-
suggested_action: {
|
|
489
|
-
tool: "septum_domain",
|
|
490
|
-
params: {
|
|
491
|
-
action: "register",
|
|
492
|
-
name: "core",
|
|
493
|
-
root: "src",
|
|
494
|
-
ingest_now: true,
|
|
495
|
-
},
|
|
496
|
-
},
|
|
497
|
-
agent_guidance: agentGuidance,
|
|
498
|
-
...(runtimeVersion.update_available
|
|
499
|
-
? {
|
|
500
|
-
agent_instruction: `Update available: v${runtimeVersion.server_version} -> v${runtimeVersion.latest_version}. Recommend running '${runtimeVersion.upgrade_command}' and reloading the MCP server if schema/features differ.`,
|
|
501
|
-
}
|
|
502
|
-
: {}),
|
|
503
|
-
};
|
|
396
|
+
const diagnostic = buildUnindexedCatalog(root, runtimeVersion);
|
|
504
397
|
return {
|
|
505
398
|
content: [
|
|
506
399
|
{
|
|
@@ -512,14 +405,14 @@ export async function runMCPServer(): Promise<void> {
|
|
|
512
405
|
runtime_version: runtimeVersion,
|
|
513
406
|
};
|
|
514
407
|
}
|
|
515
|
-
const isRegistration = name === "
|
|
408
|
+
const isRegistration = name === "septum_map" && "action" in record && record.action === "register";
|
|
516
409
|
if (!isRegistration) {
|
|
517
410
|
return {
|
|
518
411
|
isError: true,
|
|
519
412
|
content: [
|
|
520
413
|
{
|
|
521
414
|
type: "text",
|
|
522
|
-
text: `[Septum MCP Error] Workspace '${root}' belum diinisialisasi. Jalankan 'septum init' di terminal workspace atau gunakan tool '
|
|
415
|
+
text: `[Septum MCP Error] Workspace '${root}' belum diinisialisasi. Jalankan 'septum init' di terminal workspace atau gunakan tool 'septum_map' dengan action='register' untuk mendaftarkan domain.`,
|
|
523
416
|
},
|
|
524
417
|
],
|
|
525
418
|
};
|
|
@@ -527,123 +420,29 @@ export async function runMCPServer(): Promise<void> {
|
|
|
527
420
|
}
|
|
528
421
|
|
|
529
422
|
extra?.signal?.throwIfAborted();
|
|
530
|
-
|
|
423
|
+
const isDomainRegistration = parsed.name === "septum_map" && parsed.args.action === "register";
|
|
424
|
+
lease = manager.acquire(root, { deferDiscovery: isDomainRegistration });
|
|
531
425
|
const ctx = lease.context;
|
|
532
426
|
await ctx.ready;
|
|
533
427
|
extra?.signal?.throwIfAborted();
|
|
534
|
-
|
|
535
|
-
if (
|
|
428
|
+
const registrationBeforeDiscovery = isDomainRegistration && Object.keys(ctx.config.domains).length === 0 && ctx.repo.getAllDomains().length === 0;
|
|
429
|
+
try { if (!registrationBeforeDiscovery) await ctx.watcher.flush(false, extra?.signal); }
|
|
430
|
+
catch (error) { if (!isDomainRegistration || !(error instanceof DomainRootConflictError)) throw error; }
|
|
431
|
+
if (ctx.repo.getMeta("sync_error") && !(isDomainRegistration && ctx.repo.getMeta("sync_error_code") === "DOMAIN_ROOT_CONFLICT")) {
|
|
432
|
+
throw new Error(`Workspace index synchronization failed: ${ctx.repo.getMeta("sync_error")}`);
|
|
433
|
+
}
|
|
536
434
|
ctx.config = ConfigLoader.load(undefined, ctx.root);
|
|
435
|
+
// External policy writes do not emit source watcher events. Keep this cheap
|
|
436
|
+
// ownership gate independent of full reconciliation and target JIT refresh.
|
|
437
|
+
if (!isDomainRegistration) ctx.pipeline.assertDomainOwnership(ctx.config, ctx.root);
|
|
537
438
|
ctx.evaluator.getResolver().setRepository(ctx.repo);
|
|
538
439
|
|
|
539
|
-
let activeSession = null;
|
|
540
|
-
let sessionCorruptError: Error | null = null;
|
|
541
|
-
try {
|
|
542
|
-
activeSession = SessionManager.getActiveSession(ctx.root);
|
|
543
|
-
} catch (err: any) {
|
|
544
|
-
sessionCorruptError = err instanceof Error ? err : new Error(String(err));
|
|
545
|
-
}
|
|
546
|
-
const sessionPayload = activeSession
|
|
547
|
-
? { feature_key: activeSession.feature_key, domain: activeSession.domain }
|
|
548
|
-
: null;
|
|
549
|
-
|
|
550
440
|
const executeTool = async () => {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
isError: true,
|
|
557
|
-
content: [
|
|
558
|
-
{
|
|
559
|
-
type: "text",
|
|
560
|
-
text: `[Septum Validation Error] Invalid arguments for ${name}: ${parsed.error.message}`,
|
|
561
|
-
},
|
|
562
|
-
],
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
return await handleDomainTool(ctx.repo, ctx.config, parsed.data, ctx.root, extra?.signal);
|
|
566
|
-
} else if (name === "septum_symbol") {
|
|
567
|
-
const parsed = SymbolToolSchema.safeParse(args ?? {});
|
|
568
|
-
if (!parsed.success) {
|
|
569
|
-
return {
|
|
570
|
-
isError: true,
|
|
571
|
-
content: [
|
|
572
|
-
{
|
|
573
|
-
type: "text",
|
|
574
|
-
text: `[Septum Validation Error] Invalid arguments for ${name}: ${parsed.error.message}`,
|
|
575
|
-
},
|
|
576
|
-
],
|
|
577
|
-
};
|
|
578
|
-
}
|
|
579
|
-
return await handleSymbolTool(ctx.repo, ctx.config, parsed.data, ctx.pipeline, ctx.root);
|
|
580
|
-
} else if (name === "septum_slice") {
|
|
581
|
-
const parsed = SliceToolSchema.safeParse(args ?? {});
|
|
582
|
-
if (!parsed.success) {
|
|
583
|
-
return {
|
|
584
|
-
isError: true,
|
|
585
|
-
content: [
|
|
586
|
-
{
|
|
587
|
-
type: "text",
|
|
588
|
-
text: `[Septum Validation Error] Invalid arguments for ${name}: ${parsed.error.message}`,
|
|
589
|
-
},
|
|
590
|
-
],
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
return handleSliceTool(ctx.repo, ctx.config, parsed.data, ctx.root, extra?.signal);
|
|
594
|
-
} else if (name === "septum_boundary") {
|
|
595
|
-
if (sessionCorruptError) {
|
|
596
|
-
return {
|
|
597
|
-
isError: true,
|
|
598
|
-
content: [
|
|
599
|
-
{
|
|
600
|
-
type: "text",
|
|
601
|
-
text: `[Septum Session Error] Active feature session in '.septum/session.json' is corrupted or invalid: ${sessionCorruptError.message}. Release it explicitly with 'septum_feature({action: "release", force: true})' before evaluating boundaries.`,
|
|
602
|
-
},
|
|
603
|
-
],
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
const parsed = BoundaryToolSchema.safeParse(args ?? {});
|
|
607
|
-
if (!parsed.success) {
|
|
608
|
-
return {
|
|
609
|
-
isError: true,
|
|
610
|
-
content: [
|
|
611
|
-
{
|
|
612
|
-
type: "text",
|
|
613
|
-
text: `[Septum Validation Error] Invalid arguments for ${name}: ${parsed.error.message}`,
|
|
614
|
-
},
|
|
615
|
-
],
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
return await handleBoundaryTool(ctx.evaluator, ctx.config, parsed.data, ctx.repo, ctx.root);
|
|
619
|
-
} else if (name === "septum_feature") {
|
|
620
|
-
const parsed = FeatureToolSchema.safeParse(args ?? {});
|
|
621
|
-
if (!parsed.success) {
|
|
622
|
-
return {
|
|
623
|
-
isError: true,
|
|
624
|
-
content: [
|
|
625
|
-
{
|
|
626
|
-
type: "text",
|
|
627
|
-
text: `[Septum Validation Error] Invalid arguments for ${name}: ${parsed.error.message}`,
|
|
628
|
-
},
|
|
629
|
-
],
|
|
630
|
-
};
|
|
631
|
-
}
|
|
632
|
-
if (sessionCorruptError && (parsed.data.action !== "release" || !parsed.data.force)) {
|
|
633
|
-
return {
|
|
634
|
-
isError: true,
|
|
635
|
-
content: [
|
|
636
|
-
{
|
|
637
|
-
type: "text",
|
|
638
|
-
text: `[Septum Session Error] Active feature session in '.septum/session.json' is corrupted or invalid: ${sessionCorruptError.message}. Release it explicitly with 'septum_feature({action: "release", force: true})'.`,
|
|
639
|
-
},
|
|
640
|
-
],
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
|
-
extra?.signal?.throwIfAborted();
|
|
644
|
-
return await handleFeatureTool(ctx.repo, ctx.config, parsed.data, ctx.root);
|
|
645
|
-
} else {
|
|
646
|
-
throw new Error(`Unknown tool: '${name}'`);
|
|
441
|
+
switch (parsed.name) {
|
|
442
|
+
case "septum_map": return handleMapTool(ctx.repo, ctx.config, parsed.args, ctx.root, extra?.signal);
|
|
443
|
+
case "septum_symbol": return handleSymbolTool(ctx.repo, ctx.config, parsed.args, ctx.pipeline, ctx.root, extra?.signal);
|
|
444
|
+
case "septum_slice": return handleSliceTool(ctx.repo, ctx.config, parsed.args, ctx.root, extra?.signal);
|
|
445
|
+
case "septum_boundary": return handleBoundaryTool(ctx.evaluator, ctx.config, parsed.args, ctx.repo, ctx.root);
|
|
647
446
|
}
|
|
648
447
|
};
|
|
649
448
|
|
|
@@ -653,22 +452,46 @@ export async function runMCPServer(): Promise<void> {
|
|
|
653
452
|
|
|
654
453
|
let bytesOut = 0;
|
|
655
454
|
let linesOut = 0;
|
|
455
|
+
let combinedText = "";
|
|
656
456
|
if (Array.isArray(response?.content)) {
|
|
657
457
|
for (const item of response.content) {
|
|
658
458
|
if (typeof item.text === "string") {
|
|
659
459
|
bytesOut += Buffer.byteLength(item.text, "utf8");
|
|
660
460
|
linesOut += countLines(item.text);
|
|
461
|
+
if (combinedText.length < 1500) {
|
|
462
|
+
combinedText += item.text;
|
|
463
|
+
}
|
|
661
464
|
}
|
|
662
465
|
}
|
|
663
466
|
}
|
|
664
467
|
|
|
468
|
+
const inputArgs = (args as Record<string, any>) ?? {};
|
|
469
|
+
const actionName = typeof inputArgs.action === "string" ? inputArgs.action : (typeof inputArgs.scope === "string" ? inputArgs.scope : undefined);
|
|
470
|
+
const estimatedTokens = Math.round(bytesOut / 4);
|
|
471
|
+
const bloatAlert = bytesOut >= SeptumTelemetry.BLOAT_BYTE_THRESHOLD;
|
|
472
|
+
const outputDigest = SeptumTelemetry.createOutputDigest(combinedText);
|
|
473
|
+
let outcome: string | undefined;
|
|
474
|
+
try {
|
|
475
|
+
const payload = JSON.parse(combinedText);
|
|
476
|
+
const candidate = payload.status ?? (payload.found === false ? "not_found" : undefined);
|
|
477
|
+
if (["success", "partial", "unknown", "approved", "rejected", "ambiguous", "not_found", "NOT_INDEXED", "stale_reference", "invalid_context_options", "budget_too_small"].includes(candidate)) outcome = candidate;
|
|
478
|
+
} catch { /* Non-JSON results retain transport status only. */ }
|
|
479
|
+
|
|
665
480
|
SeptumTelemetry.recordToolCall({
|
|
666
481
|
event: "tool_call_completed",
|
|
667
482
|
tool: name,
|
|
483
|
+
action: actionName,
|
|
668
484
|
duration_ms: durationMs,
|
|
669
|
-
input:
|
|
670
|
-
metrics: {
|
|
671
|
-
|
|
485
|
+
input: inputArgs,
|
|
486
|
+
metrics: {
|
|
487
|
+
bytes_out: bytesOut,
|
|
488
|
+
lines_out: linesOut,
|
|
489
|
+
estimated_tokens: estimatedTokens,
|
|
490
|
+
},
|
|
491
|
+
bloat_alert: bloatAlert,
|
|
492
|
+
output_digest: outputDigest,
|
|
493
|
+
outcome,
|
|
494
|
+
session: null,
|
|
672
495
|
status: (response as { isError?: boolean } | undefined)?.isError ? "error" : "success",
|
|
673
496
|
}, ctx.root);
|
|
674
497
|
|
|
@@ -676,13 +499,16 @@ export async function runMCPServer(): Promise<void> {
|
|
|
676
499
|
} catch (err) {
|
|
677
500
|
const durationMs = Math.round(performance.now() - startTime);
|
|
678
501
|
const errorInstance = err instanceof Error ? err : new Error(String(err));
|
|
502
|
+
const inputArgs = (args as Record<string, any>) ?? {};
|
|
503
|
+
const actionName = typeof inputArgs.action === "string" ? inputArgs.action : (typeof inputArgs.scope === "string" ? inputArgs.scope : undefined);
|
|
679
504
|
|
|
680
505
|
SeptumTelemetry.recordToolCall({
|
|
681
506
|
event: "tool_call_failed",
|
|
682
507
|
tool: name,
|
|
508
|
+
action: actionName,
|
|
683
509
|
duration_ms: durationMs,
|
|
684
|
-
input:
|
|
685
|
-
session:
|
|
510
|
+
input: inputArgs,
|
|
511
|
+
session: null,
|
|
686
512
|
status: "error",
|
|
687
513
|
error: {
|
|
688
514
|
message: errorInstance.message,
|