ask-mcp 0.4.5 → 0.4.6
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/lib/ask/mcp/adapters/tool_server.rb +27 -0
- data/lib/ask/mcp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8719aff67887e47eec36f7e8b8b7c822261cbf6e1120380580747691c4d2ef2b
|
|
4
|
+
data.tar.gz: a5c2006a33be93158838aa8fc0f0ae69c8f3a1ec2aa07fd1478cf88c50f2aa62
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5a909234ffdc34be3ee993118ae8145b971f120516e7eef66be8c1bf95b5a9b18e767a366e0abca51f5fd1d573186e60496404afeebcc2d66cc3d371a907a74
|
|
7
|
+
data.tar.gz: 8c058d280dd5da3aac82fcebe7aacddb3a7c5e8861375e987835294d99cfd6f4f79e12589f47b53773397267fbf7992a44f9548321b65cc6d6a108175fe800af
|
|
@@ -47,6 +47,9 @@ module Ask
|
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
normalized = deep_stringify_keys(arguments)
|
|
50
|
+
violation = schema_violation(tool, normalized)
|
|
51
|
+
return error_result(violation) if violation
|
|
52
|
+
|
|
50
53
|
result = tool.call(normalized)
|
|
51
54
|
wrap_result(result)
|
|
52
55
|
rescue StandardError => e
|
|
@@ -58,6 +61,30 @@ module Ask
|
|
|
58
61
|
|
|
59
62
|
private
|
|
60
63
|
|
|
64
|
+
# Rejects arguments that don't match the tool's declared schema with
|
|
65
|
+
# a clear message — an unknown or missing parameter surfaces as such
|
|
66
|
+
# instead of leaking a raw ArgumentError from deep inside the tool.
|
|
67
|
+
# A tool that declares no schema (or no properties) accepts anything,
|
|
68
|
+
# preserving the duck-typed behavior for minimal tools.
|
|
69
|
+
def schema_violation(tool, args)
|
|
70
|
+
schema = tool.params_schema
|
|
71
|
+
return nil if schema.nil? || schema.empty?
|
|
72
|
+
|
|
73
|
+
properties = schema["properties"] || schema[:properties] || {}
|
|
74
|
+
allowed = properties.keys.map(&:to_s)
|
|
75
|
+
return nil if allowed.empty?
|
|
76
|
+
|
|
77
|
+
required = Array(schema["required"] || schema[:required]).map(&:to_s)
|
|
78
|
+
|
|
79
|
+
missing = required - args.keys
|
|
80
|
+
return "Missing required parameter(s) for #{tool.name}: #{missing.join(", ")}" if missing.any?
|
|
81
|
+
|
|
82
|
+
extra = args.keys - allowed
|
|
83
|
+
return "Unknown parameter(s) #{extra.join(", ")} for #{tool.name}. Expected: #{allowed.join(", ")}" if extra.any?
|
|
84
|
+
|
|
85
|
+
nil
|
|
86
|
+
end
|
|
87
|
+
|
|
61
88
|
def wrap_result(result)
|
|
62
89
|
# Plain strings are always a success
|
|
63
90
|
if result.is_a?(String)
|
data/lib/ask/mcp/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ask-mcp
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kaka Ruto
|
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
149
149
|
- !ruby/object:Gem::Version
|
|
150
150
|
version: '0'
|
|
151
151
|
requirements: []
|
|
152
|
-
rubygems_version: 4.0.
|
|
152
|
+
rubygems_version: 4.0.18
|
|
153
153
|
specification_version: 4
|
|
154
154
|
summary: Model Context Protocol (MCP) client and server for Ruby
|
|
155
155
|
test_files: []
|