kibi-mcp 3.7.0 → 3.9.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.
@@ -57,6 +57,53 @@ function withAgentVisibleText(content, data) {
57
57
  const text = summary.length > 0 ? `${payload}\n${summary}` : payload;
58
58
  return [{ type: "text", text }, ...nonTextParts];
59
59
  }
60
+ // implements REQ-mcp-structured-text-per-host
61
+ const STRUCTURED_TEXT_ENV = "KIBI_MCP_STRUCTURED_TEXT";
62
+ /**
63
+ * Hosts known to show `structuredContent` to the agent. Embedding the data
64
+ * JSON in the text part would hand them every discovery result twice.
65
+ */
66
+ const HOSTS_READING_STRUCTURED_CONTENT = new Set([
67
+ "claude-code",
68
+ ]);
69
+ /** `Claude Code`, `claude_code` and `claude-code` name the same host. */
70
+ function hostKey(name) {
71
+ return name
72
+ .trim()
73
+ .toLowerCase()
74
+ .replace(/[^a-z0-9]+/g, "-")
75
+ .replace(/^-|-$/g, "");
76
+ }
77
+ /** The client name the host sent on initialize, when the server has one. */
78
+ function clientName(server) {
79
+ try {
80
+ const name = server?.server?.getClientVersion?.()?.name;
81
+ return typeof name === "string" ? hostKey(name) : undefined;
82
+ }
83
+ catch {
84
+ return undefined;
85
+ }
86
+ }
87
+ // implements REQ-mcp-structured-text-per-host
88
+ /**
89
+ * Whether an opted-in tool embeds its data JSON in the text part. The copy
90
+ * exists for hosts that hide `structuredContent`; a host that reads it gets
91
+ * the summary alone. `KIBI_MCP_STRUCTURED_TEXT=embed|omit` decides outright;
92
+ * otherwise the host named by `KIBI_MCP_HOST` (set by the host launchers) or
93
+ * by the client's initialize name decides, and an unknown host keeps the copy.
94
+ */
95
+ export function embedsStructuredText(server, env = process.env) {
96
+ const explicit = env[STRUCTURED_TEXT_ENV]?.trim().toLowerCase();
97
+ if (explicit === "embed")
98
+ return true;
99
+ if (explicit === "omit")
100
+ return false;
101
+ const host = env.KIBI_MCP_HOST === undefined ? "" : hostKey(env.KIBI_MCP_HOST);
102
+ if (host !== "" && HOSTS_READING_STRUCTURED_CONTENT.has(host))
103
+ return false;
104
+ const client = clientName(server);
105
+ return !(client !== undefined && HOSTS_READING_STRUCTURED_CONTENT.has(client));
106
+ }
60
107
  // implements REQ-002
61
108
  function debugLog(...args) {
62
109
  if (isMcpDebugEnabled()) {
@@ -331,7 +378,8 @@ runtime = DEFAULT_TOOLS_RUNTIME, spec, annotations, outputSchema) {
331
378
  !Array.isArray(result) &&
332
379
  "content" in result) {
333
380
  const withContent = result;
334
- const content = operationSpec.agentVisibleStructuredData === true
381
+ const content = operationSpec.agentVisibleStructuredData === true &&
382
+ embedsStructuredText(server)
335
383
  ? withAgentVisibleText(withContent.content, data)
336
384
  : withContent.content;
337
385
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-mcp",
3
- "version": "3.7.0",
3
+ "version": "3.9.0",
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.14.0",
14
- "kibi-core": "^0.20.0",
13
+ "kibi-runtime": "^2.14.1",
14
+ "kibi-core": "^0.21.0",
15
15
  "zod": "^4.3.6"
16
16
  },
17
17
  "type": "module",