@okfit/mcp 0.3.6 → 0.4.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 CHANGED
@@ -41,7 +41,7 @@ or `.config/okfit.toml`.
41
41
  | `get_concept` | One concept by id: its whole decoded frontmatter, the file's raw markdown text, its bundle-relative path, and every outgoing link. |
42
42
  | `concept_neighbors` | A concept's graph neighbours — everything it links to and everything that links to it — each with its node kind and, for a concept target, its full summary. |
43
43
  | `stale_report` | Every concept whose `stale_after` instant has passed, each with its summary and how many whole days past it, as of now or an explicit instant. |
44
- | `validate_bundle` | The same conformance and lint report `okfit validate --format json` produces, unchanged. |
44
+ | `validate_bundle` | The same conformance and lint report `okfit validate --format json` produces, unchanged. Its `engine_version` and `okf_version` match the CLI's over one bundle; `okfit_version` is this package's own version and `producer` is `@okfit/mcp`. |
45
45
 
46
46
  ## Resources
47
47
 
package/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { FileSystem, Layer, Path, Schema, Stdio } from "effect";
2
2
  import { AppDirs, Xdg } from "@effected/xdg";
3
3
  import { LoadedConcept } from "@okfit/core";
4
+ import { Distribution } from "@okfit/engine";
4
5
  import { ChildProcessSpawner } from "effect/unstable/process";
5
6
  import { Toolkit } from "effect/unstable/ai";
6
7
  //#region src/errors.d.ts
@@ -379,6 +380,18 @@ export type ValidateBundleParams = typeof ValidateBundleParams.Type;
379
380
  * @public
380
381
  */
381
382
  type PlatformServices = FileSystem.FileSystem | Path.Path | AppDirs | Xdg | Stdio.Stdio | ChildProcessSpawner.ChildProcessSpawner;
383
+ /**
384
+ * Options `ServerLayer` accepts, beyond `projectRoot`. `distribution`
385
+ * (okfit #137) names the meta-package that launched this server (currently
386
+ * only `@okfit/plugin`'s `okfit-mcp` bin shim), threaded down into
387
+ * `validate_bundle`'s rendered `JsonEnvelope`; `undefined` for a direct
388
+ * install of `@okfit/mcp`.
389
+ *
390
+ * @public
391
+ */
392
+ interface ServerOptions {
393
+ readonly distribution?: Distribution;
394
+ }
382
395
  /**
383
396
  * The whole server as one layer: the toolkit, one static resource per
384
397
  * concept (`okf://concept/<id>`, built once at boot — see
@@ -396,7 +409,7 @@ type PlatformServices = FileSystem.FileSystem | Path.Path | AppDirs | Xdg | Stdi
396
409
  *
397
410
  * @public
398
411
  */
399
- export declare const ServerLayer: (projectRoot: string) => Layer.Layer<never, never, PlatformServices>;
412
+ export declare const ServerLayer: (projectRoot: string, options?: ServerOptions) => Layer.Layer<never, never, PlatformServices>;
400
413
  //#endregion
401
414
  //#region src/toolkit.d.ts
402
415
  /**
@@ -552,7 +565,12 @@ export declare const OkfitToolkit: Toolkit.Toolkit<{
552
565
  readonly success: import("effect/Schema").Struct<{
553
566
  readonly schema: import("effect/Schema").Literal<1>;
554
567
  readonly okfit_version: import("effect/Schema").String;
568
+ readonly engine_version: import("effect/Schema").String;
555
569
  readonly producer: import("effect/Schema").String;
570
+ readonly distribution: import("effect/Schema").NullOr<import("effect/Schema").Struct<{
571
+ readonly name: import("effect/Schema").String;
572
+ readonly version: import("effect/Schema").String;
573
+ }>>;
556
574
  readonly okf_version: import("effect/Schema").String;
557
575
  readonly root: import("effect/Schema").String;
558
576
  readonly profile: import("effect/Schema").NullOr<import("effect/Schema").String>;
@@ -581,10 +599,13 @@ export declare const OkfitToolkit: Toolkit.Toolkit<{
581
599
  /**
582
600
  * The handler layer. `projectRoot` is closed over from the bin (N-21);
583
601
  * the bundle itself reloads on every call inside each handler (N-9).
602
+ * `distribution` (okfit #137) is whatever `ServerLayer` was given -- only
603
+ * `validate_bundle` renders a `JsonEnvelope`, so it is the only handler
604
+ * that needs it.
584
605
  *
585
606
  * @public
586
607
  */
587
- export declare const ToolsLayer: (projectRoot: string) => import("effect/Layer").Layer<import("effect/unstable/ai/Tool").HandlersFor<{
608
+ export declare const ToolsLayer: (projectRoot: string, distribution?: Distribution) => import("effect/Layer").Layer<import("effect/unstable/ai/Tool").HandlersFor<{
588
609
  readonly concept_neighbors: import("effect/unstable/ai/Tool").Tool<"concept_neighbors", {
589
610
  readonly parameters: import("effect/Schema").Struct<{
590
611
  readonly id: import("effect/Schema").String;
@@ -730,7 +751,12 @@ export declare const ToolsLayer: (projectRoot: string) => import("effect/Layer")
730
751
  readonly success: import("effect/Schema").Struct<{
731
752
  readonly schema: import("effect/Schema").Literal<1>;
732
753
  readonly okfit_version: import("effect/Schema").String;
754
+ readonly engine_version: import("effect/Schema").String;
733
755
  readonly producer: import("effect/Schema").String;
756
+ readonly distribution: import("effect/Schema").NullOr<import("effect/Schema").Struct<{
757
+ readonly name: import("effect/Schema").String;
758
+ readonly version: import("effect/Schema").String;
759
+ }>>;
734
760
  readonly okf_version: import("effect/Schema").String;
735
761
  readonly root: import("effect/Schema").String;
736
762
  readonly profile: import("effect/Schema").NullOr<import("effect/Schema").String>;
@@ -766,5 +792,5 @@ export declare const ToolsLayer: (projectRoot: string) => import("effect/Layer")
766
792
  */
767
793
  export declare const MCP_VERSION: string;
768
794
  //#endregion
769
- export type { PlatformServices };
795
+ export type { PlatformServices, ServerOptions };
770
796
  //# sourceMappingURL=index.d.ts.map
package/main.d.ts CHANGED
@@ -1,9 +1,16 @@
1
+ import { Distribution } from "@okfit/engine";
1
2
  //#region src/main.d.ts
2
3
  /**
3
- * The assembled okfit MCP server program.
4
+ * Options `@okfit/plugin`'s `okfit-mcp` bin shim (and only it, today) passes
5
+ * to {@link main}. `distribution` names the meta-package the server was
6
+ * launched through; omitted for a direct install of `@okfit/mcp` (okfit
7
+ * #137).
4
8
  *
5
- * @packageDocumentation
9
+ * @public
6
10
  */
11
+ export interface MainOptions {
12
+ readonly distribution?: Distribution;
13
+ }
7
14
  /**
8
15
  * Run the okfit MCP server over stdio. Owns the process.
9
16
  *
@@ -11,10 +18,12 @@
11
18
  * the `uncaughtException` and `unhandledRejection` handlers are registered
12
19
  * before `NodeRuntime`, the logger and `ServerLayer` are ever evaluated, so
13
20
  * a throw during module evaluation is still reported on stderr rather than
14
- * crashing silently. Adding a static import here would defeat that.
21
+ * crashing silently. Adding a static import here would defeat that --
22
+ * `Distribution` above is a type-only import, so it carries no runtime
23
+ * import at all.
15
24
  *
16
25
  * @public
17
26
  */
18
- export declare const main: () => Promise<void>;
27
+ export declare const main: (options?: MainOptions) => Promise<void>;
19
28
  //#endregion
20
29
  //# sourceMappingURL=main.d.ts.map
package/main.js CHANGED
@@ -1,9 +1,4 @@
1
1
  //#region src/main.ts
2
- /**
3
- * The assembled okfit MCP server program.
4
- *
5
- * @packageDocumentation
6
- */
7
2
  const FATAL_FALLBACK = "okfit-mcp: a fatal error occurred and could not be described.";
8
3
  const describe = (error) => {
9
4
  try {
@@ -24,11 +19,13 @@ const fatal = (label, error) => {
24
19
  * the `uncaughtException` and `unhandledRejection` handlers are registered
25
20
  * before `NodeRuntime`, the logger and `ServerLayer` are ever evaluated, so
26
21
  * a throw during module evaluation is still reported on stderr rather than
27
- * crashing silently. Adding a static import here would defeat that.
22
+ * crashing silently. Adding a static import here would defeat that --
23
+ * `Distribution` above is a type-only import, so it carries no runtime
24
+ * import at all.
28
25
  *
29
26
  * @public
30
27
  */
31
- const main = async () => {
28
+ const main = async (options = {}) => {
32
29
  process.on("uncaughtException", (error) => fatal("uncaught exception", error));
33
30
  process.on("unhandledRejection", (reason) => fatal("unhandled rejection", reason));
34
31
  const NodeRuntime = await import("@effect/platform-node/NodeRuntime");
@@ -37,7 +34,7 @@ const main = async () => {
37
34
  const { resolveMcpProjectRoot } = await import("./internal/projectRoot.js");
38
35
  const { ServerLayer } = await import("./server.js");
39
36
  const projectRoot = resolveMcpProjectRoot(process.env);
40
- const program = Layer.launch(ServerLayer(projectRoot).pipe(Layer.provide(OkfitPlatform), Layer.provide(Logger.layer([Logger.consolePretty()])), Layer.provide(Layer.succeed(Logger.LogToStderr, true))));
37
+ const program = Layer.launch(ServerLayer(projectRoot, options).pipe(Layer.provide(OkfitPlatform), Layer.provide(Logger.layer([Logger.consolePretty()])), Layer.provide(Layer.succeed(Logger.LogToStderr, true))));
41
38
  NodeRuntime.runMain(program, { teardown: (exit, onExit) => Exit.isSuccess(exit) || Cause.hasInterruptsOnly(exit.cause) ? onExit(0) : Runtime.defaultTeardown(exit, onExit) });
42
39
  };
43
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okfit/mcp",
3
- "version": "0.3.6",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "description": "Model Context Protocol server for okfit: query and understand Open Knowledge Format (OKF) bundles from an agent.",
6
6
  "keywords": [
@@ -47,9 +47,9 @@
47
47
  "@effect/platform-node": "4.0.0-rc.115",
48
48
  "@effected/git": "^0.15.1",
49
49
  "@effected/xdg": "^0.5.2",
50
- "@okfit/core": "0.5.0",
51
- "@okfit/engine": "0.5.0",
52
- "@okfit/profiles": "0.7.0",
50
+ "@okfit/core": "0.7.0",
51
+ "@okfit/engine": "0.7.0",
52
+ "@okfit/profiles": "0.7.2",
53
53
  "effect": "4.0.0-rc.115"
54
54
  },
55
55
  "engines": {
package/server.js CHANGED
@@ -25,7 +25,7 @@ import { GitHistory } from "@okfit/profiles";
25
25
  *
26
26
  * @public
27
27
  */
28
- const ServerLayer = (projectRoot) => Layer.mergeAll(McpServer.toolkit(OkfitToolkit).pipe(Layer.provideMerge(ToolsLayer(projectRoot))), ConceptResources(projectRoot), IndexResource(projectRoot)).pipe(Layer.provide(Layer.mergeAll(Git.layer, GitHistory.layer)), Layer.provide(McpServer.layerStdio({
28
+ const ServerLayer = (projectRoot, options = {}) => Layer.mergeAll(McpServer.toolkit(OkfitToolkit).pipe(Layer.provideMerge(ToolsLayer(projectRoot, options.distribution))), ConceptResources(projectRoot), IndexResource(projectRoot)).pipe(Layer.provide(Layer.mergeAll(Git.layer, GitHistory.layer)), Layer.provide(McpServer.layerStdio({
29
29
  name: "okfit",
30
30
  version: MCP_VERSION,
31
31
  protocols: [McpProtocol.v2025_11_25, McpProtocol.v2025_06_18]
package/toolkit.js CHANGED
@@ -18,16 +18,19 @@ const OkfitToolkit = Toolkit.make(describeVocabulary, listConcepts, getConcept,
18
18
  /**
19
19
  * The handler layer. `projectRoot` is closed over from the bin (N-21);
20
20
  * the bundle itself reloads on every call inside each handler (N-9).
21
+ * `distribution` (okfit #137) is whatever `ServerLayer` was given -- only
22
+ * `validate_bundle` renders a `JsonEnvelope`, so it is the only handler
23
+ * that needs it.
21
24
  *
22
25
  * @public
23
26
  */
24
- const ToolsLayer = (projectRoot) => OkfitToolkit.toLayer({
27
+ const ToolsLayer = (projectRoot, distribution) => OkfitToolkit.toLayer({
25
28
  describe_vocabulary: () => handleDescribeVocabulary(projectRoot),
26
29
  list_concepts: (params) => handleListConcepts(projectRoot, params),
27
30
  get_concept: (params) => handleGetConcept(projectRoot, params),
28
31
  concept_neighbors: (params) => handleConceptNeighbors(projectRoot, params),
29
32
  stale_report: (params) => handleStaleReport(projectRoot, params),
30
- validate_bundle: (params) => handleValidateBundle(projectRoot, params)
33
+ validate_bundle: (params) => handleValidateBundle(projectRoot, params, distribution)
31
34
  });
32
35
 
33
36
  //#endregion
@@ -61,11 +61,13 @@ const validateBundle = Tool.make("validate_bundle", {
61
61
  * (J-2): the field names the package that produced the report, and
62
62
  * `producer` says which package that is so a reader comparing this report
63
63
  * with `okfit validate --format json` does not read the two versions as
64
- * drift (okfit #75).
64
+ * drift (okfit #75). `distribution` is whatever `ServerLayer` was given
65
+ * (okfit #137) -- `null` unless the launching bin came through
66
+ * `@okfit/plugin`.
65
67
  *
66
68
  * @public
67
69
  */
68
- const handleValidateBundle = (projectRoot, params) => Effect.gen(function* () {
70
+ const handleValidateBundle = (projectRoot, params, distribution) => Effect.gen(function* () {
69
71
  const resolved = yield* resolveConfigOnly(projectRoot);
70
72
  const now = yield* resolveNow(params.now);
71
73
  const result = yield* run({
@@ -94,7 +96,8 @@ const handleValidateBundle = (projectRoot, params) => Effect.gen(function* () {
94
96
  }),
95
97
  exitCode: code,
96
98
  concepts: result.bundle.concepts.size,
97
- diagnostics
99
+ diagnostics,
100
+ ...distribution === void 0 ? {} : { distribution }
98
101
  });
99
102
  });
100
103
 
package/version.js CHANGED
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @public
7
7
  */
8
- const MCP_VERSION = "0.3.6";
8
+ const MCP_VERSION = "0.4.0";
9
9
 
10
10
  //#endregion
11
11
  export { MCP_VERSION };