firestore-mcp-server 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/lib/get_products_tool.rb +27 -6
- data/main.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: ece424f01edc5970502519b8bb04ebc5e56b72ead03d85b581abd0307a578eb3
|
|
4
|
+
data.tar.gz: 7f4cff1f45a62030eddb1b31573da5f2b5d9b693bd05327f2616dca865e53281
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef01187aca499e7453fa7ea99edf6ab9dfe55b88997882c09aa2e95f38aae1079e7b18892a6cb9201bd4391141974b25cd6e25c6b5352dca65b703487b3d4191
|
|
7
|
+
data.tar.gz: e17ee329c0b2426fbddbb209fba98d5b7ddc82efb97e932004209a2c3fa3df9ec6872b851639534589d818ee1f64a8a70bc0a96089e195f0c46e10b0df78e320
|
data/lib/get_products_tool.rb
CHANGED
|
@@ -11,14 +11,35 @@ class GetProductsTool < MCP::Tool
|
|
|
11
11
|
input_schema(type: 'object', properties: {})
|
|
12
12
|
|
|
13
13
|
class << self
|
|
14
|
-
def call
|
|
14
|
+
def call(*)
|
|
15
15
|
client = FirestoreClient.instance
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
return db_not_running_response unless client.db_running
|
|
17
|
+
|
|
18
|
+
products = format_products(client.products)
|
|
19
|
+
MCP::Tool::Response.new([{ type: 'text', text: products.to_json }])
|
|
20
|
+
rescue StandardError => e
|
|
21
|
+
error_response(e)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def format_products(products)
|
|
27
|
+
products.map do |p|
|
|
28
|
+
p[:timestamp] = p[:timestamp].to_s if p[:timestamp]
|
|
29
|
+
p[:actualdateadded] = p[:actualdateadded].to_s if p[:actualdateadded]
|
|
30
|
+
p
|
|
21
31
|
end
|
|
22
32
|
end
|
|
33
|
+
|
|
34
|
+
def db_not_running_response
|
|
35
|
+
MCP::Tool::Response.new([{ type: 'text', text: 'Inventory database is not running.' }])
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def error_response(error)
|
|
39
|
+
MCP::Tool::Response.new(
|
|
40
|
+
[{ type: 'text', text: "Error getting products: #{error.message}" }],
|
|
41
|
+
is_error: true
|
|
42
|
+
)
|
|
43
|
+
end
|
|
23
44
|
end
|
|
24
45
|
end
|
data/main.rb
CHANGED