ask-mcp 0.4.3 → 0.4.5
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/lib/ask/mcp/adapters/tool_server.rb +34 -6
- data/lib/ask/mcp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5d5c902336445279874512b3b83fea5c1f19b0de0640ceefe6d0bc61c6dd6f4e
|
|
4
|
+
data.tar.gz: a4b94e8307ef2d7b8aa2b2a6fee63a14dd45584f910f6db1c1db4b0826728699
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef659cb4cedd858c26a7cb8acb5a5cbef3f7dc4d4ec8bd88967cfbcb0437e94d333eb34d7336147298b172ea04fd1715bcae7e2de2ba5133e0b3b81a3d3cd1bf
|
|
7
|
+
data.tar.gz: 2bf513b38edd2eb62c72ad385908c7483972d11a802f22c5f6b7f8389110d55f2650c5c7ac6ba4a733a135a5de3424b35f2437455d43f466667dfe22c1a3c88d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
## [0.4.5] - 2026-08-12
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- **`structuredContent` mirroring in ToolServer results** — success results
|
|
6
|
+
now include a machine-readable `structuredContent` field (MCP 2025-06-18)
|
|
7
|
+
populated from the JSON text when it parses to an object or array. MCP
|
|
8
|
+
clients that render structured views (e.g. ZCode's "Structured content"
|
|
9
|
+
section) now display the parsed result instead of an empty block. Plain
|
|
10
|
+
text and `:summary` shorthand outputs are unaffected.
|
|
11
|
+
|
|
12
|
+
## [0.4.4] - 2026-08-10
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **Hash tool results are JSON-serialized instead of emitted raw** —
|
|
17
|
+
`ToolServer#wrap_result`/`success_result` used `result[:summary]` as the
|
|
18
|
+
content `text` whenever a Hash result had a `summary` key. When `summary`
|
|
19
|
+
was itself a Hash (e.g. `schema_graph`'s summary), the server emitted a
|
|
20
|
+
non-string content item that spec-compliant MCP clients reject. String
|
|
21
|
+
`summary` values are still honored as a shorthand; any other Hash result is
|
|
22
|
+
`JSON.generate`d so `text` is always a String.
|
|
23
|
+
|
|
1
24
|
## [0.4.3] - 2026-08-04
|
|
2
25
|
|
|
3
26
|
### Added
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
3
5
|
module Ask
|
|
4
6
|
module MCP
|
|
5
7
|
module Adapters
|
|
@@ -59,7 +61,7 @@ module Ask
|
|
|
59
61
|
def wrap_result(result)
|
|
60
62
|
# Plain strings are always a success
|
|
61
63
|
if result.is_a?(String)
|
|
62
|
-
return
|
|
64
|
+
return text_result(result)
|
|
63
65
|
end
|
|
64
66
|
|
|
65
67
|
# Result-like objects (Ask::Result, OpenStruct, etc.)
|
|
@@ -69,21 +71,47 @@ module Ask
|
|
|
69
71
|
return error_result(result.respond_to?(:error_message) ? result.error_message : result.to_s)
|
|
70
72
|
end
|
|
71
73
|
|
|
72
|
-
# Everything else — treat as success
|
|
73
|
-
text
|
|
74
|
-
|
|
74
|
+
# Everything else — treat as success. Hashes are JSON-serialized so
|
|
75
|
+
# the content text is always a String (MCP content items require
|
|
76
|
+
# string `text`). A String `:summary` is honored as a shorthand.
|
|
77
|
+
text = if result.is_a?(Hash)
|
|
78
|
+
result[:summary].is_a?(String) ? result[:summary] : JSON.generate(result)
|
|
79
|
+
else
|
|
80
|
+
result.to_s
|
|
81
|
+
end
|
|
82
|
+
text_result(text)
|
|
75
83
|
end
|
|
76
84
|
|
|
77
85
|
def success_result(result, _ok)
|
|
78
86
|
output = result.respond_to?(:output) ? result.output : result.to_s
|
|
79
|
-
text = output.is_a?(Hash)
|
|
80
|
-
|
|
87
|
+
text = if output.is_a?(Hash)
|
|
88
|
+
output[:summary].is_a?(String) ? output[:summary] : JSON.generate(output)
|
|
89
|
+
else
|
|
90
|
+
output.to_s
|
|
91
|
+
end
|
|
92
|
+
text_result(text)
|
|
81
93
|
end
|
|
82
94
|
|
|
83
95
|
def error_result(message)
|
|
84
96
|
{ content: [{ type: "text", text: "Error: #{message}" }], isError: true }
|
|
85
97
|
end
|
|
86
98
|
|
|
99
|
+
# Builds a success result. Mirrors JSON text into `structuredContent`
|
|
100
|
+
# (MCP 2025-06-18) when it parses, so clients can render a structured
|
|
101
|
+
# view instead of an empty section.
|
|
102
|
+
def text_result(text)
|
|
103
|
+
{ content: [{ type: "text", text: text }], isError: false }.merge(structured_content_for(text))
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def structured_content_for(text)
|
|
107
|
+
parsed = JSON.parse(text)
|
|
108
|
+
return {} unless parsed.is_a?(Hash) || parsed.is_a?(Array)
|
|
109
|
+
|
|
110
|
+
{ structuredContent: parsed }
|
|
111
|
+
rescue JSON::ParserError
|
|
112
|
+
{}
|
|
113
|
+
end
|
|
114
|
+
|
|
87
115
|
def deep_stringify_keys(obj)
|
|
88
116
|
case obj
|
|
89
117
|
when Hash then obj.each_with_object({}) { |(k, v), h| h[k.to_s] = deep_stringify_keys(v) }
|
data/lib/ask/mcp/version.rb
CHANGED