tina4ruby 3.13.33 → 3.13.35
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/tina4/dev_admin.rb +31 -0
- data/lib/tina4/mcp.rb +16 -6
- data/lib/tina4/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: 9cdb8976e4e87658d1655be468112a986b32817f18f5415d96c8744d3f2b179c
|
|
4
|
+
data.tar.gz: d2f3c50d3b646e062d38c088090b0919c347ecec1b130edcd661c0921b743846
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 37f1743a3ef8f314baf055c84bf7696174b5977af5b2d9e87b5ceb5e93ed2d6a4870d4dcf2ca7e75f3e4e4734368274e84c4160c94199c7da59d57f5f5432194
|
|
7
|
+
data.tar.gz: addb86d53bfc8d864dd93bc3dc52015c21e133590109ae91d262f082ecf55368acada387097b2e9340fddc5ae1443ba0bb5dd085492d6e2b2e5f90a81eb582cb
|
data/lib/tina4/dev_admin.rb
CHANGED
|
@@ -614,6 +614,14 @@ module Tina4
|
|
|
614
614
|
when ["POST", "/__dev/api/mcp/call"]
|
|
615
615
|
body = read_json_body(env) || {}
|
|
616
616
|
json_response(mcp_tool_call(body))
|
|
617
|
+
# JSON-RPC + SSE endpoints that real MCP clients (Claude Code/Desktop)
|
|
618
|
+
# speak. Mounted on the same dispatch as the REST shim above and gated
|
|
619
|
+
# on the same enabled? (TINA4_DEBUG) check, so disabled → 404. They
|
|
620
|
+
# share the default MCP server's tool registry with the REST shim.
|
|
621
|
+
when ["POST", "/__dev/mcp"], ["POST", "/__dev/mcp/message"]
|
|
622
|
+
mcp_jsonrpc(env)
|
|
623
|
+
when ["GET", "/__dev/mcp/sse"]
|
|
624
|
+
mcp_sse_handshake
|
|
617
625
|
when ["GET", "/__dev/api/scaffold"]
|
|
618
626
|
json_response(scaffold_templates)
|
|
619
627
|
when ["POST", "/__dev/api/scaffold/run"]
|
|
@@ -1431,6 +1439,29 @@ module Tina4
|
|
|
1431
1439
|
JSON.parse(raw)
|
|
1432
1440
|
end
|
|
1433
1441
|
|
|
1442
|
+
# Native MCP JSON-RPC endpoint (POST /__dev/mcp[/message]). Real MCP
|
|
1443
|
+
# clients POST a JSON-RPC 2.0 request; we hand the parsed body straight
|
|
1444
|
+
# to the default server's handle_message and echo the response. A
|
|
1445
|
+
# notification (no id) yields an empty 204, mirroring Python.
|
|
1446
|
+
def mcp_jsonrpc(env)
|
|
1447
|
+
body = read_json_body(env) || {}
|
|
1448
|
+
server = Tina4._default_mcp_server
|
|
1449
|
+
raw = server.handle_message(body)
|
|
1450
|
+
if raw.nil? || raw.empty?
|
|
1451
|
+
[204, { "content-type" => "application/json; charset=utf-8" }, []]
|
|
1452
|
+
else
|
|
1453
|
+
[200, { "content-type" => "application/json; charset=utf-8" }, [raw]]
|
|
1454
|
+
end
|
|
1455
|
+
end
|
|
1456
|
+
|
|
1457
|
+
# SSE handshake (GET /__dev/mcp/sse). Tells the client where to POST
|
|
1458
|
+
# JSON-RPC messages via the standard `endpoint` event, then the client
|
|
1459
|
+
# switches to POST /__dev/mcp/message. Body + content-type match Python.
|
|
1460
|
+
def mcp_sse_handshake
|
|
1461
|
+
body = "event: endpoint\ndata: /__dev/mcp/message\n\n"
|
|
1462
|
+
[200, { "content-type" => "text/event-stream" }, [body]]
|
|
1463
|
+
end
|
|
1464
|
+
|
|
1434
1465
|
def scaffold_templates
|
|
1435
1466
|
# Expose built-in scaffold targets for the dev-admin UI.
|
|
1436
1467
|
{ templates: [
|
data/lib/tina4/mcp.rb
CHANGED
|
@@ -423,8 +423,17 @@ module Tina4
|
|
|
423
423
|
|
|
424
424
|
@_default_mcp_server = nil
|
|
425
425
|
|
|
426
|
+
# The default dev MCP server, mounted at /__dev/mcp. Built lazily on first
|
|
427
|
+
# access and pre-loaded with the built-in dev tools (database_query,
|
|
428
|
+
# file_read, route_list, …) so both the REST shim (/__dev/api/mcp/*) and
|
|
429
|
+
# the JSON-RPC + SSE endpoints (/__dev/mcp[/message], /__dev/mcp/sse)
|
|
430
|
+
# share one fully-populated tool registry.
|
|
426
431
|
def self._default_mcp_server
|
|
427
|
-
@_default_mcp_server ||=
|
|
432
|
+
@_default_mcp_server ||= begin
|
|
433
|
+
server = McpServer.new("/__dev/mcp", name: "Tina4 Dev Tools")
|
|
434
|
+
McpDevTools.register(server)
|
|
435
|
+
server
|
|
436
|
+
end
|
|
428
437
|
end
|
|
429
438
|
|
|
430
439
|
# Register a block as an MCP tool.
|
|
@@ -661,12 +670,13 @@ module Tina4
|
|
|
661
670
|
|
|
662
671
|
# ── Route Tools ───────────────────────────────────
|
|
663
672
|
server.register_tool("route_list", lambda {
|
|
664
|
-
|
|
665
|
-
|
|
673
|
+
# Tina4::Router.routes returns Route objects (attr_readers), not
|
|
674
|
+
# Hashes — use accessors, never [] subscript.
|
|
675
|
+
Tina4::Router.routes.map do |route|
|
|
666
676
|
{
|
|
667
|
-
"method" => route
|
|
668
|
-
"path" => route
|
|
669
|
-
"auth_required" =>
|
|
677
|
+
"method" => route.method.to_s,
|
|
678
|
+
"path" => route.path.to_s,
|
|
679
|
+
"auth_required" => route.auth_required ? true : false
|
|
670
680
|
}
|
|
671
681
|
end
|
|
672
682
|
}, "List all registered routes")
|
data/lib/tina4/version.rb
CHANGED