kibi-mcp 3.12.0 → 3.14.1
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/dist/server/tools.js +27 -2
- package/dist/server/transport.js +12 -0
- package/dist/server.js +2 -1
- package/package.json +3 -3
package/dist/server/tools.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
import process from "node:process";
|
|
19
|
-
import { QUERY_LIMIT_EXCEEDED_CODE, detachedReadOnlyDiagnostic, executeOperation, queryLimitExceededOf, } from "kibi-runtime";
|
|
19
|
+
import { QUERY_LIMIT_EXCEEDED_CODE, codedErrorOf, detachedReadOnlyDiagnostic, executeOperation, queryLimitExceededOf, } from "kibi-runtime";
|
|
20
20
|
import { operationData, toKibiResult } from "kibi-runtime";
|
|
21
21
|
import { routedBusinessArgs, routedOperationName } from "../diagnostics.js";
|
|
22
22
|
import { isMcpDebugEnabled } from "../env.js";
|
|
@@ -259,7 +259,7 @@ function observeDetachedReads(base) {
|
|
|
259
259
|
notice: () => notice,
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
|
-
// implements REQ-002
|
|
262
|
+
// implements REQ-002, REQ-mcp-coded-error-envelope
|
|
263
263
|
export function addTool(server, name, description, inputSchema, handler,
|
|
264
264
|
// INTENTIONAL: DEFAULT_TOOLS_RUNTIME is typed as ToolsRuntime<PrologProcess>; the
|
|
265
265
|
// generic TProlog parameter exists so tests can inject a mock type. The cast is safe
|
|
@@ -476,6 +476,31 @@ runtime = DEFAULT_TOOLS_RUNTIME, spec, annotations, outputSchema) {
|
|
|
476
476
|
isError: true,
|
|
477
477
|
};
|
|
478
478
|
}
|
|
479
|
+
const coded = codedErrorOf(error);
|
|
480
|
+
if (coded !== null) {
|
|
481
|
+
// An error that carries a Kibi code (VALIDATION_FAILED and the
|
|
482
|
+
// like) answers with the same error envelope the CLI JSON route
|
|
483
|
+
// prints, so a client can branch on error.code instead of parsing
|
|
484
|
+
// the message.
|
|
485
|
+
const envelope = withWorkspaceNotice(withWorkspaceNotice(toKibiResult(operationSpec, null, {
|
|
486
|
+
status: "error",
|
|
487
|
+
error: {
|
|
488
|
+
code: coded.code,
|
|
489
|
+
message: coded.message,
|
|
490
|
+
retryable: coded.retryable,
|
|
491
|
+
},
|
|
492
|
+
}), workspaceNotice), observed.notice());
|
|
493
|
+
return {
|
|
494
|
+
content: [
|
|
495
|
+
{
|
|
496
|
+
type: "text",
|
|
497
|
+
text: `Tool ${name} failed: [${coded.code}] ${coded.message}`,
|
|
498
|
+
},
|
|
499
|
+
],
|
|
500
|
+
structuredContent: envelope,
|
|
501
|
+
isError: true,
|
|
502
|
+
};
|
|
503
|
+
}
|
|
479
504
|
throw error;
|
|
480
505
|
}
|
|
481
506
|
finally {
|
package/dist/server/transport.js
CHANGED
|
@@ -23,6 +23,18 @@ function debugLog(...args) {
|
|
|
23
23
|
console.error(...args);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* stdout carries the JSON-RPC stream. Operations shared with the CLI (kibi
|
|
28
|
+
* sync, kibi migrate, kibi branch ensure) report progress with console.log,
|
|
29
|
+
* so route the console methods that write to stdout to stderr before the
|
|
30
|
+
* transport connects; the transport itself writes to process.stdout directly.
|
|
31
|
+
*/
|
|
32
|
+
// implements REQ-002
|
|
33
|
+
export function keepStdoutForProtocol() {
|
|
34
|
+
for (const method of ["log", "info", "debug"]) {
|
|
35
|
+
console[method] = (...args) => console.error(...args);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
26
38
|
export function setupTransportHandlers(_server, transport) {
|
|
27
39
|
transport.onerror = (error) => {
|
|
28
40
|
// Stdio transport surfaces JSON parse / schema validation failures via onerror.
|
package/dist/server.js
CHANGED
|
@@ -23,7 +23,7 @@ import { loadDefaultEnvFile } from "./env.js";
|
|
|
23
23
|
import { setupDocsAndPrompts } from "./server/docs.js";
|
|
24
24
|
import { KIBI_ICONS } from "./server/icons.js";
|
|
25
25
|
import { registerAllTools } from "./server/tools.js";
|
|
26
|
-
import { connectTransport, setupTransportHandlers, } from "./server/transport.js";
|
|
26
|
+
import { connectTransport, keepStdoutForProtocol, setupTransportHandlers, } from "./server/transport.js";
|
|
27
27
|
import { WorkspaceRouter, setWorkspaceRouter, } from "./server/workspace-router.js";
|
|
28
28
|
import { resolveWorkspaceRoot } from "./workspace.js";
|
|
29
29
|
// Read version from package.json to prevent drift
|
|
@@ -37,6 +37,7 @@ const SERVER_INSTRUCTIONS = [
|
|
|
37
37
|
"Confirm branch freshness with kb_status. For first-time repository setup, use the kibi-bootstrap prompt.",
|
|
38
38
|
].join(" ");
|
|
39
39
|
export async function startServer() {
|
|
40
|
+
keepStdoutForProtocol();
|
|
40
41
|
// Load environment configuration
|
|
41
42
|
loadDefaultEnvFile();
|
|
42
43
|
// Initialize diagnostic mode if --diagnostic-mode flag is present
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kibi-mcp",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.1",
|
|
4
4
|
"mcpName": "io.github.Looted/kibi-mcp",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"fast-glob": "^3.2.12",
|
|
11
11
|
"gray-matter": "^4.0.3",
|
|
12
12
|
"js-yaml": "^4.1.0",
|
|
13
|
-
"kibi-runtime": "^2.16.
|
|
14
|
-
"kibi-core": "^0.22.
|
|
13
|
+
"kibi-runtime": "^2.16.2",
|
|
14
|
+
"kibi-core": "^0.22.2",
|
|
15
15
|
"zod": "^4.3.6"
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|