@ifc-lite/mcp 0.2.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.
Files changed (155) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +186 -0
  3. package/dist/auth/index.d.ts +3 -0
  4. package/dist/auth/index.d.ts.map +1 -0
  5. package/dist/auth/index.js +5 -0
  6. package/dist/auth/index.js.map +1 -0
  7. package/dist/auth/scope.d.ts +24 -0
  8. package/dist/auth/scope.d.ts.map +1 -0
  9. package/dist/auth/scope.js +26 -0
  10. package/dist/auth/scope.js.map +1 -0
  11. package/dist/browser.d.ts +37 -0
  12. package/dist/browser.d.ts.map +1 -0
  13. package/dist/browser.js +37 -0
  14. package/dist/browser.js.map +1 -0
  15. package/dist/cli.d.ts +3 -0
  16. package/dist/cli.d.ts.map +1 -0
  17. package/dist/cli.js +233 -0
  18. package/dist/cli.js.map +1 -0
  19. package/dist/context.d.ts +87 -0
  20. package/dist/context.d.ts.map +1 -0
  21. package/dist/context.js +41 -0
  22. package/dist/context.js.map +1 -0
  23. package/dist/errors.d.ts +37 -0
  24. package/dist/errors.d.ts.map +1 -0
  25. package/dist/errors.js +49 -0
  26. package/dist/errors.js.map +1 -0
  27. package/dist/headless-backend.d.ts +61 -0
  28. package/dist/headless-backend.d.ts.map +1 -0
  29. package/dist/headless-backend.js +472 -0
  30. package/dist/headless-backend.js.map +1 -0
  31. package/dist/index.d.ts +39 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +49 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/loader.d.ts +9 -0
  36. package/dist/loader.d.ts.map +1 -0
  37. package/dist/loader.js +76 -0
  38. package/dist/loader.js.map +1 -0
  39. package/dist/prompts/index.d.ts +6 -0
  40. package/dist/prompts/index.d.ts.map +1 -0
  41. package/dist/prompts/index.js +13 -0
  42. package/dist/prompts/index.js.map +1 -0
  43. package/dist/prompts/templates.d.ts +21 -0
  44. package/dist/prompts/templates.d.ts.map +1 -0
  45. package/dist/prompts/templates.js +238 -0
  46. package/dist/prompts/templates.js.map +1 -0
  47. package/dist/prompts/types.d.ts +17 -0
  48. package/dist/prompts/types.d.ts.map +1 -0
  49. package/dist/prompts/types.js +27 -0
  50. package/dist/prompts/types.js.map +1 -0
  51. package/dist/protocol/index.d.ts +3 -0
  52. package/dist/protocol/index.d.ts.map +1 -0
  53. package/dist/protocol/index.js +6 -0
  54. package/dist/protocol/index.js.map +1 -0
  55. package/dist/protocol/jsonrpc.d.ts +12 -0
  56. package/dist/protocol/jsonrpc.d.ts.map +1 -0
  57. package/dist/protocol/jsonrpc.js +62 -0
  58. package/dist/protocol/jsonrpc.js.map +1 -0
  59. package/dist/protocol/types.d.ts +223 -0
  60. package/dist/protocol/types.d.ts.map +1 -0
  61. package/dist/protocol/types.js +37 -0
  62. package/dist/protocol/types.js.map +1 -0
  63. package/dist/resources/index.d.ts +6 -0
  64. package/dist/resources/index.d.ts.map +1 -0
  65. package/dist/resources/index.js +13 -0
  66. package/dist/resources/index.js.map +1 -0
  67. package/dist/resources/providers.d.ts +3 -0
  68. package/dist/resources/providers.d.ts.map +1 -0
  69. package/dist/resources/providers.js +270 -0
  70. package/dist/resources/providers.js.map +1 -0
  71. package/dist/resources/types.d.ts +29 -0
  72. package/dist/resources/types.d.ts.map +1 -0
  73. package/dist/resources/types.js +30 -0
  74. package/dist/resources/types.js.map +1 -0
  75. package/dist/server.d.ts +93 -0
  76. package/dist/server.d.ts.map +1 -0
  77. package/dist/server.js +396 -0
  78. package/dist/server.js.map +1 -0
  79. package/dist/tools/bcf.d.ts +3 -0
  80. package/dist/tools/bcf.d.ts.map +1 -0
  81. package/dist/tools/bcf.js +208 -0
  82. package/dist/tools/bcf.js.map +1 -0
  83. package/dist/tools/bsdd.d.ts +3 -0
  84. package/dist/tools/bsdd.d.ts.map +1 -0
  85. package/dist/tools/bsdd.js +267 -0
  86. package/dist/tools/bsdd.js.map +1 -0
  87. package/dist/tools/diff.d.ts +3 -0
  88. package/dist/tools/diff.d.ts.map +1 -0
  89. package/dist/tools/diff.js +149 -0
  90. package/dist/tools/diff.js.map +1 -0
  91. package/dist/tools/discovery.d.ts +8 -0
  92. package/dist/tools/discovery.d.ts.map +1 -0
  93. package/dist/tools/discovery.js +181 -0
  94. package/dist/tools/discovery.js.map +1 -0
  95. package/dist/tools/export.d.ts +3 -0
  96. package/dist/tools/export.d.ts.map +1 -0
  97. package/dist/tools/export.js +157 -0
  98. package/dist/tools/export.js.map +1 -0
  99. package/dist/tools/geometry.d.ts +3 -0
  100. package/dist/tools/geometry.d.ts.map +1 -0
  101. package/dist/tools/geometry.js +252 -0
  102. package/dist/tools/geometry.js.map +1 -0
  103. package/dist/tools/ids-accessor.d.ts +9 -0
  104. package/dist/tools/ids-accessor.d.ts.map +1 -0
  105. package/dist/tools/ids-accessor.js +131 -0
  106. package/dist/tools/ids-accessor.js.map +1 -0
  107. package/dist/tools/index.d.ts +21 -0
  108. package/dist/tools/index.d.ts.map +1 -0
  109. package/dist/tools/index.js +36 -0
  110. package/dist/tools/index.js.map +1 -0
  111. package/dist/tools/mutate.d.ts +3 -0
  112. package/dist/tools/mutate.d.ts.map +1 -0
  113. package/dist/tools/mutate.js +350 -0
  114. package/dist/tools/mutate.js.map +1 -0
  115. package/dist/tools/query.d.ts +3 -0
  116. package/dist/tools/query.d.ts.map +1 -0
  117. package/dist/tools/query.js +549 -0
  118. package/dist/tools/query.js.map +1 -0
  119. package/dist/tools/types.d.ts +18 -0
  120. package/dist/tools/types.d.ts.map +1 -0
  121. package/dist/tools/types.js +26 -0
  122. package/dist/tools/types.js.map +1 -0
  123. package/dist/tools/util.d.ts +19 -0
  124. package/dist/tools/util.d.ts.map +1 -0
  125. package/dist/tools/util.js +53 -0
  126. package/dist/tools/util.js.map +1 -0
  127. package/dist/tools/validation.d.ts +3 -0
  128. package/dist/tools/validation.d.ts.map +1 -0
  129. package/dist/tools/validation.js +244 -0
  130. package/dist/tools/validation.js.map +1 -0
  131. package/dist/tools/viewer.d.ts +3 -0
  132. package/dist/tools/viewer.d.ts.map +1 -0
  133. package/dist/tools/viewer.js +651 -0
  134. package/dist/tools/viewer.js.map +1 -0
  135. package/dist/transport/http.d.ts +64 -0
  136. package/dist/transport/http.d.ts.map +1 -0
  137. package/dist/transport/http.js +268 -0
  138. package/dist/transport/http.js.map +1 -0
  139. package/dist/transport/in-process.d.ts +25 -0
  140. package/dist/transport/in-process.d.ts.map +1 -0
  141. package/dist/transport/in-process.js +48 -0
  142. package/dist/transport/in-process.js.map +1 -0
  143. package/dist/transport/stdio.d.ts +33 -0
  144. package/dist/transport/stdio.d.ts.map +1 -0
  145. package/dist/transport/stdio.js +86 -0
  146. package/dist/transport/stdio.js.map +1 -0
  147. package/dist/validate.d.ts +23 -0
  148. package/dist/validate.d.ts.map +1 -0
  149. package/dist/validate.js +88 -0
  150. package/dist/validate.js.map +1 -0
  151. package/dist/viewer-manager.d.ts +51 -0
  152. package/dist/viewer-manager.d.ts.map +1 -0
  153. package/dist/viewer-manager.js +183 -0
  154. package/dist/viewer-manager.js.map +1 -0
  155. package/package.json +86 -0
@@ -0,0 +1,93 @@
1
+ /**
2
+ * MCPServer β€” the central JSON-RPC router.
3
+ *
4
+ * Responsibilities:
5
+ * - track initialization handshake
6
+ * - dispatch `tools/list`, `tools/call`, `resources/list`, `resources/read`,
7
+ * `prompts/list`, `prompts/get`, `ping`, `notifications/initialized`,
8
+ * `notifications/cancelled`
9
+ * - filter tool advertisement by auth scope
10
+ * - validate tool input against the tool's JSON schema
11
+ * - turn thrown ToolExecutionError into structured tool results (NOT JSON-RPC errors)
12
+ *
13
+ * Transport-agnostic: `connect(transport)` is the only I/O hook. The transport
14
+ * pushes incoming JSON-RPC messages via `handleMessage` and gets back zero or
15
+ * one outgoing messages plus any progress/log notifications routed through
16
+ * the `OutgoingMessageSink` contract.
17
+ */
18
+ import { JsonRpcMessage, JsonRpcResponse, ServerCapabilities } from './protocol/index.js';
19
+ import { AuthScope } from './auth/scope.js';
20
+ import { Logger, ModelRegistry, ServerConfig } from './context.js';
21
+ import { PromptRegistry } from './prompts/types.js';
22
+ import { ResourceRegistry } from './resources/types.js';
23
+ import { ToolRegistry } from './tools/types.js';
24
+ import { ViewerManager } from './viewer-manager.js';
25
+ export declare const SERVER_NAME = "ifc-lite-mcp";
26
+ export interface OutgoingMessageSink {
27
+ send(message: JsonRpcMessage): Promise<void> | void;
28
+ }
29
+ export interface MCPServerOptions {
30
+ name?: string;
31
+ version: string;
32
+ registry?: ModelRegistry;
33
+ scope?: AuthScope;
34
+ config?: Partial<ServerConfig>;
35
+ tools: ToolRegistry;
36
+ resources: ResourceRegistry;
37
+ prompts: PromptRegistry;
38
+ logger?: Logger;
39
+ /** Override which capabilities are advertised. */
40
+ capabilities?: ServerCapabilities;
41
+ /** Optional pre-built viewer manager. Default: a fresh one bound to the registry. */
42
+ viewer?: ViewerManager;
43
+ }
44
+ export declare class MCPServer {
45
+ readonly name: string;
46
+ readonly version: string;
47
+ readonly registry: ModelRegistry;
48
+ readonly tools: ToolRegistry;
49
+ readonly resources: ResourceRegistry;
50
+ readonly prompts: PromptRegistry;
51
+ readonly config: ServerConfig;
52
+ readonly viewer: ViewerManager;
53
+ private scope;
54
+ private logger;
55
+ private capabilities;
56
+ private initialized;
57
+ private sink;
58
+ /** Active tool calls keyed by JSON-RPC id, used for cancellation. */
59
+ private active;
60
+ /** Currently subscribed resource URIs (for `notifications/resources/updated`). */
61
+ private subscriptions;
62
+ constructor(opts: MCPServerOptions);
63
+ /** Attach an outgoing-message sink. Required before handling messages. */
64
+ attach(sink: OutgoingMessageSink): void;
65
+ detach(): void;
66
+ /** Update the auth scope mid-session (e.g. token refresh). */
67
+ setScope(scope: AuthScope): void;
68
+ isInitialized(): boolean;
69
+ /**
70
+ * Process a single inbound JSON-RPC message. Returns the response (if any)
71
+ * or null for notifications. Side-effect notifications (progress, log) flow
72
+ * through the attached sink, not the return value.
73
+ */
74
+ handleMessage(message: JsonRpcMessage): Promise<JsonRpcResponse | null>;
75
+ private handleRequest;
76
+ private handleNotification;
77
+ private handleInitialize;
78
+ private handleListTools;
79
+ private handleCallTool;
80
+ private handleListResources;
81
+ private handleReadResource;
82
+ private handleListPrompts;
83
+ private handleGetPrompt;
84
+ private makeResourceContext;
85
+ private makeProgress;
86
+ /** Broadcast a `notifications/resources/updated` to subscribers. */
87
+ notifyResourceUpdated(uri: string): void;
88
+ /** Notify clients that the tool list has changed (e.g., after model load). */
89
+ notifyToolsChanged(): void;
90
+ /** Read-only access to the auth scope for transports that need to gate access. */
91
+ hasModelAccess(modelId: string): boolean;
92
+ }
93
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAQL,cAAc,EAEd,eAAe,EASf,kBAAkB,EAGnB,MAAM,qBAAqB,CAAC;AAQ7B,OAAO,EACL,SAAS,EAIV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGL,MAAM,EACN,aAAa,EAGb,YAAY,EAEb,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,eAAO,MAAM,WAAW,iBAAiB,CAAC;AAE1C,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,KAAK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IAAI,CAAC;YAiB/D,aAAa;YA+Cb,kBAAkB;IA4BhC,OAAO,CAAC,gBAAgB;IA8BxB,OAAO,CAAC,eAAe;YAcT,cAAc;YA0Ed,mBAAmB;YAMnB,kBAAkB;IAiBhC,OAAO,CAAC,iBAAiB;YAIX,eAAe;IAgB7B,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,YAAY;IAepB,oEAAoE;IACpE,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMxC,8EAA8E;IAC9E,kBAAkB,IAAI,IAAI;IAK1B,kFAAkF;IAClF,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;CAGzC"}
package/dist/server.js ADDED
@@ -0,0 +1,396 @@
1
+ /* This Source Code Form is subject to the terms of the Mozilla Public
2
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
+ /**
5
+ * MCPServer β€” the central JSON-RPC router.
6
+ *
7
+ * Responsibilities:
8
+ * - track initialization handshake
9
+ * - dispatch `tools/list`, `tools/call`, `resources/list`, `resources/read`,
10
+ * `prompts/list`, `prompts/get`, `ping`, `notifications/initialized`,
11
+ * `notifications/cancelled`
12
+ * - filter tool advertisement by auth scope
13
+ * - validate tool input against the tool's JSON schema
14
+ * - turn thrown ToolExecutionError into structured tool results (NOT JSON-RPC errors)
15
+ *
16
+ * Transport-agnostic: `connect(transport)` is the only I/O hook. The transport
17
+ * pushes incoming JSON-RPC messages via `handleMessage` and gets back zero or
18
+ * one outgoing messages plus any progress/log notifications routed through
19
+ * the `OutgoingMessageSink` contract.
20
+ */
21
+ import { JsonRpcErrorCode, PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, } from './protocol/index.js';
22
+ import { errorResponse, isJsonRpcNotification, isJsonRpcRequest, notification, successResponse, } from './protocol/jsonrpc.js';
23
+ import { fullScope, modelAllowed, scopeAllows, } from './auth/scope.js';
24
+ import { DEFAULT_CONFIG, InMemoryModelRegistry, SILENT_LOGGER, } from './context.js';
25
+ import { ToolExecutionError, ToolErrorCode, toolError } from './errors.js';
26
+ import { validateInput } from './validate.js';
27
+ import { ViewerManager } from './viewer-manager.js';
28
+ export const SERVER_NAME = 'ifc-lite-mcp';
29
+ export class MCPServer {
30
+ name;
31
+ version;
32
+ registry;
33
+ tools;
34
+ resources;
35
+ prompts;
36
+ config;
37
+ viewer;
38
+ scope;
39
+ logger;
40
+ capabilities;
41
+ initialized = false;
42
+ sink = null;
43
+ /** Active tool calls keyed by JSON-RPC id, used for cancellation. */
44
+ active = new Map();
45
+ /** Currently subscribed resource URIs (for `notifications/resources/updated`). */
46
+ subscriptions = new Set();
47
+ constructor(opts) {
48
+ this.name = opts.name ?? SERVER_NAME;
49
+ this.version = opts.version;
50
+ this.registry = opts.registry ?? new InMemoryModelRegistry();
51
+ this.scope = opts.scope ?? fullScope();
52
+ this.config = { ...DEFAULT_CONFIG, ...(opts.config ?? {}) };
53
+ this.tools = opts.tools;
54
+ this.resources = opts.resources;
55
+ this.prompts = opts.prompts;
56
+ this.logger = opts.logger ?? SILENT_LOGGER;
57
+ this.capabilities = opts.capabilities ?? {
58
+ tools: { listChanged: true },
59
+ resources: { subscribe: true, listChanged: true },
60
+ prompts: { listChanged: false },
61
+ logging: {},
62
+ };
63
+ this.viewer = opts.viewer ?? new ViewerManager((id) => (id ? this.registry.get(id) : null));
64
+ // Selection changes ripple out as resource updates so subscribed agents
65
+ // see live picks without polling.
66
+ this.viewer.onSelection((_sel, model) => {
67
+ const uri = model
68
+ ? `ifc-lite://model/${model.id}/viewer/selection`
69
+ : 'ifc-lite://viewer/selection';
70
+ this.notifyResourceUpdated(uri);
71
+ this.notifyResourceUpdated('ifc-lite://viewer/selection');
72
+ });
73
+ }
74
+ /** Attach an outgoing-message sink. Required before handling messages. */
75
+ attach(sink) {
76
+ this.sink = sink;
77
+ }
78
+ detach() {
79
+ this.sink = null;
80
+ this.active.forEach((c) => c.abort());
81
+ this.active.clear();
82
+ // The viewer holds an HTTP server + SSE listener; closing it stops
83
+ // dangling sockets when the transport disconnects.
84
+ if (this.viewer.isOpen())
85
+ this.viewer.close();
86
+ }
87
+ /** Update the auth scope mid-session (e.g. token refresh). */
88
+ setScope(scope) {
89
+ this.scope = scope;
90
+ }
91
+ isInitialized() {
92
+ return this.initialized;
93
+ }
94
+ /**
95
+ * Process a single inbound JSON-RPC message. Returns the response (if any)
96
+ * or null for notifications. Side-effect notifications (progress, log) flow
97
+ * through the attached sink, not the return value.
98
+ */
99
+ async handleMessage(message) {
100
+ if (isJsonRpcRequest(message)) {
101
+ return this.handleRequest(message);
102
+ }
103
+ if (isJsonRpcNotification(message)) {
104
+ await this.handleNotification(message);
105
+ return null;
106
+ }
107
+ // Responses to server-initiated requests would land here; v0.1 has no
108
+ // server-initiated requests so we just drop them.
109
+ return null;
110
+ }
111
+ // ────────────────────────────────────────────────────────────────────────
112
+ // Request dispatch
113
+ // ────────────────────────────────────────────────────────────────────────
114
+ async handleRequest(req) {
115
+ try {
116
+ // initialize/ping always allowed regardless of init state.
117
+ if (req.method === 'initialize') {
118
+ return successResponse(req.id, this.handleInitialize(req.params));
119
+ }
120
+ if (req.method === 'ping') {
121
+ return successResponse(req.id, {});
122
+ }
123
+ if (!this.initialized) {
124
+ return errorResponse(req.id, JsonRpcErrorCode.ServerNotInitialized, 'Server not initialized β€” send `initialize` first');
125
+ }
126
+ switch (req.method) {
127
+ case 'tools/list':
128
+ return successResponse(req.id, this.handleListTools());
129
+ case 'tools/call':
130
+ return successResponse(req.id, await this.handleCallTool(req));
131
+ case 'resources/list':
132
+ return successResponse(req.id, await this.handleListResources());
133
+ case 'resources/read':
134
+ return successResponse(req.id, await this.handleReadResource(req.params));
135
+ case 'resources/subscribe':
136
+ this.subscriptions.add(req.params.uri);
137
+ return successResponse(req.id, {});
138
+ case 'resources/unsubscribe':
139
+ this.subscriptions.delete(req.params.uri);
140
+ return successResponse(req.id, {});
141
+ case 'prompts/list':
142
+ return successResponse(req.id, this.handleListPrompts());
143
+ case 'prompts/get':
144
+ return successResponse(req.id, await this.handleGetPrompt(req.params));
145
+ default:
146
+ return errorResponse(req.id, JsonRpcErrorCode.MethodNotFound, `Unknown method: ${req.method}`);
147
+ }
148
+ }
149
+ catch (err) {
150
+ const message = err instanceof Error ? err.message : String(err);
151
+ this.logger.log('error', `Request ${req.method} failed`, { error: message });
152
+ return errorResponse(req.id, JsonRpcErrorCode.InternalError, message);
153
+ }
154
+ }
155
+ async handleNotification(note) {
156
+ switch (note.method) {
157
+ case 'notifications/initialized':
158
+ // Some clients send this AFTER `initialize`. Already initialized in the
159
+ // success path; this notification is just a confirmation.
160
+ this.initialized = true;
161
+ return;
162
+ case 'notifications/cancelled': {
163
+ const params = note.params;
164
+ if (params?.requestId !== undefined) {
165
+ const ctl = this.active.get(params.requestId);
166
+ if (ctl) {
167
+ ctl.abort();
168
+ this.active.delete(params.requestId);
169
+ this.logger.log('info', `Cancelled request ${params.requestId}`, { reason: params.reason });
170
+ }
171
+ }
172
+ return;
173
+ }
174
+ default:
175
+ this.logger.log('debug', `Ignored notification ${note.method}`);
176
+ }
177
+ }
178
+ // ────────────────────────────────────────────────────────────────────────
179
+ // initialize
180
+ // ────────────────────────────────────────────────────────────────────────
181
+ handleInitialize(params) {
182
+ this.initialized = true;
183
+ // Per MCP spec: when the client requests a protocol version we support,
184
+ // echo it back; otherwise reply with our preferred version. Newer
185
+ // clients (e.g. Claude Desktop β‰₯ 0.x asking for 2025-11-25) hard-close
186
+ // the transport on a version mismatch, so silently downgrading them
187
+ // would brick the integration. Our wire surface is the stable subset
188
+ // (initialize, tools/{list,call}, resources/*, prompts/*, notifications/*,
189
+ // logging) that's been compatible across these revisions, so accepting
190
+ // them is safe.
191
+ const negotiated = SUPPORTED_PROTOCOL_VERSIONS.has(params.protocolVersion)
192
+ ? params.protocolVersion
193
+ : PROTOCOL_VERSION;
194
+ this.logger.log('info', 'initialize', {
195
+ client: params.clientInfo,
196
+ protocol: params.protocolVersion,
197
+ negotiated,
198
+ });
199
+ return {
200
+ protocolVersion: negotiated,
201
+ capabilities: this.capabilities,
202
+ serverInfo: { name: this.name, version: this.version },
203
+ instructions: SERVER_INSTRUCTIONS,
204
+ };
205
+ }
206
+ // ────────────────────────────────────────────────────────────────────────
207
+ // tools/*
208
+ // ────────────────────────────────────────────────────────────────────────
209
+ handleListTools() {
210
+ const visible = this.tools.list().filter((t) => scopeAllows(this.scope, t.scope));
211
+ if (this.config.readOnly) {
212
+ // belt-and-suspenders: even if a token claims `mutate`, hide mutation
213
+ // tools when the server was started --read-only.
214
+ const tools = visible
215
+ .filter((t) => t.scope !== 'mutate')
216
+ .map(toToolDefinition);
217
+ return { tools };
218
+ }
219
+ const tools = visible.map(toToolDefinition);
220
+ return { tools };
221
+ }
222
+ async handleCallTool(req) {
223
+ const params = req.params;
224
+ const tool = this.tools.get(params.name);
225
+ if (!tool) {
226
+ return toolError({
227
+ code: ToolErrorCode.UNSUPPORTED_OPERATION,
228
+ message: `Unknown tool: ${params.name}`,
229
+ hint: 'Use `tools/list` to discover available tools.',
230
+ });
231
+ }
232
+ if (!scopeAllows(this.scope, tool.scope)) {
233
+ return toolError({
234
+ code: ToolErrorCode.PERMISSION_DENIED,
235
+ message: `Tool '${params.name}' requires scope '${tool.scope}'`,
236
+ details: { required: tool.scope, granted: this.scope.scopes },
237
+ });
238
+ }
239
+ if (this.config.readOnly && tool.scope === 'mutate') {
240
+ return toolError({
241
+ code: ToolErrorCode.READ_ONLY,
242
+ message: `Server started in read-only mode; '${params.name}' rejected.`,
243
+ });
244
+ }
245
+ const validation = validateInput(tool.inputSchema, params.arguments ?? {});
246
+ if (!validation.valid) {
247
+ return toolError({
248
+ code: ToolErrorCode.INVALID_INPUT,
249
+ message: `Input validation failed for ${params.name}`,
250
+ details: { errors: validation.errors },
251
+ hint: 'Inspect `details.errors` for the offending field paths.',
252
+ });
253
+ }
254
+ const ctl = new AbortController();
255
+ this.active.set(req.id, ctl);
256
+ const progressToken = params._meta?.progressToken;
257
+ const progress = this.makeProgress(progressToken);
258
+ const ctx = {
259
+ registry: this.registry,
260
+ scope: this.scope,
261
+ progress,
262
+ log: this.logger,
263
+ signal: ctl.signal,
264
+ config: this.config,
265
+ viewer: this.viewer,
266
+ };
267
+ const startedAt = Date.now();
268
+ try {
269
+ const result = await tool.handler(validation.value, ctx);
270
+ this.logger.log('info', `tools/call ${params.name}`, {
271
+ latencyMs: Date.now() - startedAt,
272
+ isError: result.isError === true,
273
+ });
274
+ return result;
275
+ }
276
+ catch (err) {
277
+ this.logger.log('error', `tools/call ${params.name} threw`, {
278
+ error: err instanceof Error ? err.message : String(err),
279
+ });
280
+ if (err instanceof ToolExecutionError)
281
+ return err.toToolResult();
282
+ return toolError({
283
+ code: ToolErrorCode.INTERNAL_ERROR,
284
+ message: err instanceof Error ? err.message : String(err),
285
+ });
286
+ }
287
+ finally {
288
+ this.active.delete(req.id);
289
+ }
290
+ }
291
+ // ────────────────────────────────────────────────────────────────────────
292
+ // resources/*
293
+ // ────────────────────────────────────────────────────────────────────────
294
+ async handleListResources() {
295
+ const ctx = this.makeResourceContext();
296
+ const resources = await this.resources.list(ctx);
297
+ return { resources };
298
+ }
299
+ async handleReadResource(params) {
300
+ const provider = this.resources.matchProvider(params.uri);
301
+ if (!provider) {
302
+ throw new ToolExecutionError({
303
+ code: ToolErrorCode.UNSUPPORTED_OPERATION,
304
+ message: `No resource provider matches URI: ${params.uri}`,
305
+ });
306
+ }
307
+ const ctx = this.makeResourceContext();
308
+ const contents = await provider.read(params.uri, ctx);
309
+ return { contents };
310
+ }
311
+ // ────────────────────────────────────────────────────────────────────────
312
+ // prompts/*
313
+ // ────────────────────────────────────────────────────────────────────────
314
+ handleListPrompts() {
315
+ return { prompts: this.prompts.list() };
316
+ }
317
+ async handleGetPrompt(params) {
318
+ const prompt = this.prompts.get(params.name);
319
+ if (!prompt) {
320
+ throw new ToolExecutionError({
321
+ code: ToolErrorCode.UNSUPPORTED_OPERATION,
322
+ message: `Unknown prompt: ${params.name}`,
323
+ });
324
+ }
325
+ const ctx = this.makeResourceContext();
326
+ return prompt.render(params.arguments ?? {}, ctx);
327
+ }
328
+ // ────────────────────────────────────────────────────────────────────────
329
+ // helpers
330
+ // ────────────────────────────────────────────────────────────────────────
331
+ makeResourceContext() {
332
+ return {
333
+ registry: this.registry,
334
+ scope: this.scope,
335
+ progress: { report() { } },
336
+ log: this.logger,
337
+ signal: new AbortController().signal,
338
+ config: this.config,
339
+ viewer: this.viewer,
340
+ };
341
+ }
342
+ makeProgress(token) {
343
+ if (token === undefined || !this.sink) {
344
+ return { report() { } };
345
+ }
346
+ const sink = this.sink;
347
+ return {
348
+ report: (progress, message, total) => {
349
+ const note = { progressToken: token, progress };
350
+ if (total !== undefined)
351
+ note.total = total;
352
+ if (message !== undefined)
353
+ note.message = message;
354
+ void sink.send(notification('notifications/progress', note));
355
+ },
356
+ };
357
+ }
358
+ /** Broadcast a `notifications/resources/updated` to subscribers. */
359
+ notifyResourceUpdated(uri) {
360
+ if (!this.sink)
361
+ return;
362
+ if (!this.subscriptions.has(uri))
363
+ return;
364
+ void this.sink.send(notification('notifications/resources/updated', { uri }));
365
+ }
366
+ /** Notify clients that the tool list has changed (e.g., after model load). */
367
+ notifyToolsChanged() {
368
+ if (!this.sink)
369
+ return;
370
+ void this.sink.send(notification('notifications/tools/list_changed', {}));
371
+ }
372
+ /** Read-only access to the auth scope for transports that need to gate access. */
373
+ hasModelAccess(modelId) {
374
+ return modelAllowed(this.scope, modelId);
375
+ }
376
+ }
377
+ function toToolDefinition(tool) {
378
+ return {
379
+ name: tool.name,
380
+ description: tool.description,
381
+ inputSchema: tool.inputSchema,
382
+ scope: tool.scope,
383
+ };
384
+ }
385
+ const SERVER_INSTRUCTIONS = `
386
+ ifc-lite-mcp exposes a federated set of IFC/BIM models as MCP tools.
387
+
388
+ Conventions:
389
+ β€’ All tools accept an optional model_id; when only one model is loaded it can be omitted.
390
+ β€’ Errors surface as tool results with isError=true and structuredContent.code (e.g. ENTITY_NOT_FOUND).
391
+ β€’ Long operations stream progress via notifications/progress when a progressToken is supplied.
392
+ β€’ Mutations are queued; call export_ifc or model_save to persist.
393
+
394
+ See the resource ifc-lite://server/manifest for the full tool catalog.
395
+ `.trim();
396
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAOL,gBAAgB,EAOhB,gBAAgB,EAChB,2BAA2B,GAO5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,SAAS,EACT,YAAY,EACZ,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,cAAc,EACd,qBAAqB,EAIrB,aAAa,GAGd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI3E,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC;AAsB1C,MAAM,OAAO,SAAS;IACX,IAAI,CAAS;IACb,OAAO,CAAS;IAChB,QAAQ,CAAgB;IACxB,KAAK,CAAe;IACpB,SAAS,CAAmB;IAC5B,OAAO,CAAiB;IACxB,MAAM,CAAe;IACrB,MAAM,CAAgB;IAEvB,KAAK,CAAY;IACjB,MAAM,CAAS;IACf,YAAY,CAAqB;IACjC,WAAW,GAAG,KAAK,CAAC;IACpB,IAAI,GAA+B,IAAI,CAAC;IAChD,qEAAqE;IAC7D,MAAM,GAAG,IAAI,GAAG,EAAoC,CAAC;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,CAAC;gBAClD,KAAK,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC,CAAC;YAC/D,CAAC;SACF,CAAC;IACJ,CAAC;IAED,oEAAoE;IACpE,qBAAqB,CAAC,GAAW;QAC/B,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO;QACvB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO;QACzC,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,iCAAiC,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,8EAA8E;IAC9E,kBAAkB;QAChB,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO;QACvB,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,kFAAkF;IAClF,cAAc,CAAC,OAAe;QAC5B,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;CACF;AAED,SAAS,gBAAgB,CAAC,IAAiF;IACzG,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,WAAW,EAAE,IAAI,CAAC,WAA4C;QAC9D,KAAK,EAAE,IAAI,CAAC,KAAgC;KAC7C,CAAC;AACJ,CAAC;AAED,MAAM,mBAAmB,GAAG;;;;;;;;;;CAU3B,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Tool } from './types.js';
2
+ export declare const bcfTools: Tool[];
3
+ //# sourceMappingURL=bcf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bcf.d.ts","sourceRoot":"","sources":["../../src/tools/bcf.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAyMvC,eAAO,MAAM,QAAQ,EAAE,IAAI,EAAiG,CAAC"}