@okfit/mcp 0.4.2 → 0.5.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/errors.js +6 -2
- package/index.d.ts +31 -8
- package/index.js +2 -2
- package/package.json +8 -8
- package/server.js +42 -8
- package/version.js +1 -1
package/errors.js
CHANGED
|
@@ -15,8 +15,12 @@ const Remediation = Schema.Struct({
|
|
|
15
15
|
* collapses a caught typed failure to
|
|
16
16
|
* `{ isError: true, content: [{ type: "text", text: error.message }] }`
|
|
17
17
|
* and never surfaces `structuredContent` for it
|
|
18
|
-
* (`.repos/effect/packages/effect/src/unstable/ai/McpServer.ts:
|
|
19
|
-
*
|
|
18
|
+
* (`.repos/effect/packages/effect/src/unstable/ai/McpServer.ts:1774-1778,1842-1846`
|
|
19
|
+
* at effect@4.0.0-rc.116: `toolErrorResult` and `declaredFailureResult`'s
|
|
20
|
+
* `error instanceof Error` branch; confirmed empirically in Task B1's own
|
|
21
|
+
* build). Since rc.116 that declared branch is rendered WITHOUT a log line
|
|
22
|
+
* — only an internal failure goes through `Effect.logError` — so the
|
|
23
|
+
* message text is the whole of what a client ever sees. `remediation` itself is
|
|
20
24
|
* left on the schema unchanged, both for anything that inspects the typed
|
|
21
25
|
* error directly (a defect handler, a future in-process caller) and
|
|
22
26
|
* because it is what this function reads to build `message`.
|
package/index.d.ts
CHANGED
|
@@ -21,8 +21,12 @@ export type Remediation = typeof Remediation.Type;
|
|
|
21
21
|
* collapses a caught typed failure to
|
|
22
22
|
* `{ isError: true, content: [{ type: "text", text: error.message }] }`
|
|
23
23
|
* and never surfaces `structuredContent` for it
|
|
24
|
-
* (`.repos/effect/packages/effect/src/unstable/ai/McpServer.ts:
|
|
25
|
-
*
|
|
24
|
+
* (`.repos/effect/packages/effect/src/unstable/ai/McpServer.ts:1774-1778,1842-1846`
|
|
25
|
+
* at effect@4.0.0-rc.116: `toolErrorResult` and `declaredFailureResult`'s
|
|
26
|
+
* `error instanceof Error` branch; confirmed empirically in Task B1's own
|
|
27
|
+
* build). Since rc.116 that declared branch is rendered WITHOUT a log line
|
|
28
|
+
* — only an internal failure goes through `Effect.logError` — so the
|
|
29
|
+
* message text is the whole of what a client ever sees. `remediation` itself is
|
|
26
30
|
* left on the schema unchanged, both for anything that inspects the typed
|
|
27
31
|
* error directly (a defect handler, a future in-process caller) and
|
|
28
32
|
* because it is what this function reads to build `message`.
|
|
@@ -392,20 +396,39 @@ type PlatformServices = FileSystem.FileSystem | Path.Path | AppDirs | Xdg | Stdi
|
|
|
392
396
|
interface ServerOptions {
|
|
393
397
|
readonly distribution?: Distribution;
|
|
394
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* Agent-facing orientation, surfaced verbatim as `instructions` in both the
|
|
401
|
+
* `initialize` result (2025-11-25 / 2025-06-18) and the `server/discover`
|
|
402
|
+
* result (2026-07-28). `description` on the server identity stays the
|
|
403
|
+
* one-line human summary; this is the paragraph an agent reads before its
|
|
404
|
+
* first call. Exported so tests can assert identity rather than a
|
|
405
|
+
* substring.
|
|
406
|
+
*
|
|
407
|
+
* @public
|
|
408
|
+
*/
|
|
409
|
+
export declare const SERVER_INSTRUCTIONS: string;
|
|
395
410
|
/**
|
|
396
411
|
* The whole server as one layer: the toolkit, one static resource per
|
|
397
412
|
* concept (`okf://concept/<id>`, built once at boot — see
|
|
398
413
|
* {@link ConceptResources}), and `okf://index` (re-read from disk on every
|
|
399
414
|
* call), over `McpServer.layerStdio`.
|
|
400
415
|
*
|
|
401
|
-
* `protocols` ships
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
416
|
+
* `protocols` ships three adapters, newest first. `McpProtocol.v2026_07_28`
|
|
417
|
+
* is the stateless adapter (SEP-2575): no `initialize`, no session, every
|
|
418
|
+
* request self-identifies through `params._meta`, and the client discovers
|
|
419
|
+
* the server with `server/discover`. The two stateful adapters stay
|
|
420
|
+
* because `initialize` matches stateful adapters only — a client that
|
|
421
|
+
* opens with `initialize` (Claude Code by default, Copilot, Cursor, the
|
|
422
|
+
* Inspector) would otherwise get `METHOD_NOT_FOUND`. Array order is
|
|
423
|
+
* load-bearing: a request with no session and no `_meta` protocol version
|
|
424
|
+
* falls to `protocols[0]`, and `server/discover` advertises every listed
|
|
425
|
+
* adapter in `supportedVersions`. The runtime allows at most one stateless
|
|
426
|
+
* adapter; a second fails the layer with `Cause.IllegalArgumentError`.
|
|
427
|
+
* Never reduce this to one entry.
|
|
405
428
|
*
|
|
406
429
|
* `Cause.IllegalArgumentError` in `layerStdio`'s signature is left
|
|
407
|
-
* unhandled: `protocols` is a static
|
|
408
|
-
*
|
|
430
|
+
* unhandled: `protocols` is a static literal, so it is an implementer-time
|
|
431
|
+
* defect, not a runtime condition.
|
|
409
432
|
*
|
|
410
433
|
* @public
|
|
411
434
|
*/
|
package/index.js
CHANGED
|
@@ -5,6 +5,6 @@ import { ConceptSummary, toConceptSummary } from "./schema/ConceptSummary.js";
|
|
|
5
5
|
import { ConceptNeighborsSuccess, DescribeVocabularySuccess, GetConceptSuccess, ListConceptsParams, ListConceptsSuccess, Neighbor, StaleReportParams, StaleReportSuccess, ValidateBundleParams } from "./schema/tools.js";
|
|
6
6
|
import { MCP_VERSION } from "./version.js";
|
|
7
7
|
import { OkfitToolkit, ToolsLayer } from "./toolkit.js";
|
|
8
|
-
import { ServerLayer } from "./server.js";
|
|
8
|
+
import { SERVER_INSTRUCTIONS, ServerLayer } from "./server.js";
|
|
9
9
|
|
|
10
|
-
export { BundleNotFound, ConceptNeighborsSuccess, ConceptNotFound, ConceptResources, ConceptSummary, ConfigError, DescribeVocabularySuccess, GetConceptSuccess, IndexResource, InvalidArgument, ListConceptsParams, ListConceptsSuccess, MCP_VERSION, McpToolError, Neighbor, OkfitToolkit, Remediation, ServerLayer, StaleReportParams, StaleReportSuccess, ToolsLayer, UnknownVocabulary, ValidateBundleParams, composeRemediatedMessage, toConceptSummary, truncateEchoed };
|
|
10
|
+
export { BundleNotFound, ConceptNeighborsSuccess, ConceptNotFound, ConceptResources, ConceptSummary, ConfigError, DescribeVocabularySuccess, GetConceptSuccess, IndexResource, InvalidArgument, ListConceptsParams, ListConceptsSuccess, MCP_VERSION, McpToolError, Neighbor, OkfitToolkit, Remediation, SERVER_INSTRUCTIONS, ServerLayer, StaleReportParams, StaleReportSuccess, ToolsLayer, UnknownVocabulary, ValidateBundleParams, composeRemediatedMessage, toConceptSummary, truncateEchoed };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okfit/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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": [
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
"okfit-mcp": "bin/okfit-mcp.js"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@effect/platform-node": "4.0.0-rc.
|
|
48
|
-
"@effected/git": "^0.
|
|
49
|
-
"@effected/xdg": "^0.
|
|
50
|
-
"@okfit/core": "0.7.
|
|
51
|
-
"@okfit/engine": "0.7.
|
|
52
|
-
"@okfit/profiles": "0.7.
|
|
53
|
-
"effect": "4.0.0-rc.
|
|
47
|
+
"@effect/platform-node": "4.0.0-rc.116",
|
|
48
|
+
"@effected/git": "^0.16.0",
|
|
49
|
+
"@effected/xdg": "^0.6.0",
|
|
50
|
+
"@okfit/core": "0.7.2",
|
|
51
|
+
"@okfit/engine": "0.7.3",
|
|
52
|
+
"@okfit/profiles": "0.7.4",
|
|
53
|
+
"effect": "4.0.0-rc.116"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=24.11.0"
|
package/server.js
CHANGED
|
@@ -9,27 +9,61 @@ import { GitHistory } from "@okfit/profiles";
|
|
|
9
9
|
|
|
10
10
|
//#region src/server.ts
|
|
11
11
|
/**
|
|
12
|
+
* Agent-facing orientation, surfaced verbatim as `instructions` in both the
|
|
13
|
+
* `initialize` result (2025-11-25 / 2025-06-18) and the `server/discover`
|
|
14
|
+
* result (2026-07-28). `description` on the server identity stays the
|
|
15
|
+
* one-line human summary; this is the paragraph an agent reads before its
|
|
16
|
+
* first call. Exported so tests can assert identity rather than a
|
|
17
|
+
* substring.
|
|
18
|
+
*
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
const SERVER_INSTRUCTIONS = [
|
|
22
|
+
"okfit-mcp serves one Open Knowledge Format (OKF) bundle: the okf/ directory of the project it was launched in.",
|
|
23
|
+
"Every tool is read-only and answers from the bundle as it is on disk at call time.",
|
|
24
|
+
"Start with describe_vocabulary to learn the concept types and tags this project's config declares, then",
|
|
25
|
+
"list_concepts to find ids; get_concept, concept_neighbors, stale_report and validate_bundle take those ids.",
|
|
26
|
+
"Concept ids are bundle-relative paths without the .md extension (for example decisions/cli-exit-codes).",
|
|
27
|
+
"Every successful tools/call result carries the typed payload in structuredContent and a JSON rendering in",
|
|
28
|
+
"content[0].text. A failed call is isError: true with the human message and a remediation hint in",
|
|
29
|
+
"content[0].text and no structuredContent; read that text before retrying.",
|
|
30
|
+
"Resources: okf://index is the bundle's root index.md, and okf://concept/<id> is one static resource per concept."
|
|
31
|
+
].join(" ");
|
|
32
|
+
/**
|
|
12
33
|
* The whole server as one layer: the toolkit, one static resource per
|
|
13
34
|
* concept (`okf://concept/<id>`, built once at boot — see
|
|
14
35
|
* {@link ConceptResources}), and `okf://index` (re-read from disk on every
|
|
15
36
|
* call), over `McpServer.layerStdio`.
|
|
16
37
|
*
|
|
17
|
-
* `protocols` ships
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
38
|
+
* `protocols` ships three adapters, newest first. `McpProtocol.v2026_07_28`
|
|
39
|
+
* is the stateless adapter (SEP-2575): no `initialize`, no session, every
|
|
40
|
+
* request self-identifies through `params._meta`, and the client discovers
|
|
41
|
+
* the server with `server/discover`. The two stateful adapters stay
|
|
42
|
+
* because `initialize` matches stateful adapters only — a client that
|
|
43
|
+
* opens with `initialize` (Claude Code by default, Copilot, Cursor, the
|
|
44
|
+
* Inspector) would otherwise get `METHOD_NOT_FOUND`. Array order is
|
|
45
|
+
* load-bearing: a request with no session and no `_meta` protocol version
|
|
46
|
+
* falls to `protocols[0]`, and `server/discover` advertises every listed
|
|
47
|
+
* adapter in `supportedVersions`. The runtime allows at most one stateless
|
|
48
|
+
* adapter; a second fails the layer with `Cause.IllegalArgumentError`.
|
|
49
|
+
* Never reduce this to one entry.
|
|
21
50
|
*
|
|
22
51
|
* `Cause.IllegalArgumentError` in `layerStdio`'s signature is left
|
|
23
|
-
* unhandled: `protocols` is a static
|
|
24
|
-
*
|
|
52
|
+
* unhandled: `protocols` is a static literal, so it is an implementer-time
|
|
53
|
+
* defect, not a runtime condition.
|
|
25
54
|
*
|
|
26
55
|
* @public
|
|
27
56
|
*/
|
|
28
57
|
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
58
|
name: "okfit",
|
|
30
59
|
version: MCP_VERSION,
|
|
31
|
-
|
|
60
|
+
instructions: SERVER_INSTRUCTIONS,
|
|
61
|
+
protocols: [
|
|
62
|
+
McpProtocol.v2026_07_28,
|
|
63
|
+
McpProtocol.v2025_11_25,
|
|
64
|
+
McpProtocol.v2025_06_18
|
|
65
|
+
]
|
|
32
66
|
})), Layer.orDie);
|
|
33
67
|
|
|
34
68
|
//#endregion
|
|
35
|
-
export { ServerLayer };
|
|
69
|
+
export { SERVER_INSTRUCTIONS, ServerLayer };
|