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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d5c902336445279874512b3b83fea5c1f19b0de0640ceefe6d0bc61c6dd6f4e
4
- data.tar.gz: a4b94e8307ef2d7b8aa2b2a6fee63a14dd45584f910f6db1c1db4b0826728699
3
+ metadata.gz: 8719aff67887e47eec36f7e8b8b7c822261cbf6e1120380580747691c4d2ef2b
4
+ data.tar.gz: a5c2006a33be93158838aa8fc0f0ae69c8f3a1ec2aa07fd1478cf88c50f2aa62
5
5
  SHA512:
6
- metadata.gz: ef659cb4cedd858c26a7cb8acb5a5cbef3f7dc4d4ec8bd88967cfbcb0437e94d333eb34d7336147298b172ea04fd1715bcae7e2de2ba5133e0b3b81a3d3cd1bf
7
- data.tar.gz: 2bf513b38edd2eb62c72ad385908c7483972d11a802f22c5f6b7f8389110d55f2650c5c7ac6ba4a733a135a5de3424b35f2437455d43f466667dfe22c1a3c88d
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)
@@ -1,5 +1,5 @@
1
1
  module Ask
2
2
  module MCP
3
- VERSION = "0.4.5"
3
+ VERSION = "0.4.6"
4
4
  end
5
5
  end
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.5
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.3
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: []