Skip to main content

soma_api/
route_inventory.rs

1// `RestRoute` (the generic route-metadata shape) and `CapabilitiesResponse`
2// live in `soma-http-api` (plan section 3.11) — reusable across any product
3// built on this workspace. `REST_ROUTES` below is Soma's own concrete route
4// table and stays here.
5pub use soma_http_api::route_inventory::{CapabilitiesResponse, RestRoute};
6
7pub(crate) const GATEWAY_ROUTE_PATH: &str = "/v1/gateway/{action}";
8
9pub const REST_ROUTES: &[RestRoute] = &[
10    RestRoute {
11        method: "GET",
12        path: "/health",
13        action: None,
14        auth: "public",
15        description: "Fast liveness probe.",
16    },
17    RestRoute {
18        method: "GET",
19        path: "/readyz",
20        action: None,
21        auth: "public",
22        description: "Readiness probe; 503 when the upstream dependency is unreachable.",
23    },
24    RestRoute {
25        method: "GET",
26        path: "/metrics",
27        action: None,
28        auth: "public",
29        description:
30            "Prometheus metrics (text exposition format; requires the observability feature).",
31    },
32    RestRoute {
33        method: "GET",
34        path: "/status",
35        action: None,
36        auth: "public",
37        description: "Local redacted runtime status.",
38    },
39    RestRoute {
40        method: "GET",
41        path: "/openapi.json",
42        action: None,
43        auth: "public",
44        description: "Generated OpenAPI schema.",
45    },
46    RestRoute {
47        method: "GET",
48        path: "/v1/capabilities",
49        action: None,
50        auth: "mounted auth policy",
51        description: "Direct REST route inventory and server metadata.",
52    },
53    RestRoute {
54        method: "GET",
55        path: "/v1/providers",
56        action: None,
57        auth: "mounted auth policy",
58        description: "Live provider catalog, including dropped provider tools and MCP primitives.",
59    },
60    RestRoute {
61        method: "POST",
62        path: "/v1/tools/{action}",
63        action: None,
64        auth: "mounted auth policy; requires the provider tool scope when scoped",
65        description: "Generic REST execution route for provider-backed tools.",
66    },
67    RestRoute {
68        method: "POST",
69        path: GATEWAY_ROUTE_PATH,
70        action: None,
71        auth:
72            "mounted auth policy; read actions require soma:read, admin actions require soma:admin",
73        description: "Gateway management and discovery action dispatch.",
74    },
75    RestRoute {
76        method: "POST",
77        path: "/v1/greet",
78        action: Some("greet"),
79        auth: "mounted auth policy; requires soma:read when scoped",
80        description: "Return a greeting.",
81    },
82    RestRoute {
83        method: "POST",
84        path: "/v1/echo",
85        action: Some("echo"),
86        auth: "mounted auth policy; requires soma:read when scoped",
87        description: "Echo a message back unchanged.",
88    },
89    RestRoute {
90        method: "GET",
91        path: "/v1/status",
92        action: Some("status"),
93        auth: "mounted auth policy; requires soma:read when scoped",
94        description: "Return authenticated service status.",
95    },
96    RestRoute {
97        method: "GET",
98        path: "/v1/help",
99        action: Some("help"),
100        auth: "mounted auth policy",
101        description: "Return the action catalog and route help.",
102    },
103];
104
105pub(crate) fn capabilities_response() -> CapabilitiesResponse {
106    soma_http_api::route_inventory::capabilities_response(
107        "soma-mcp",
108        env!("CARGO_PKG_VERSION"),
109        "direct_routes",
110        REST_ROUTES,
111    )
112}
113
114#[cfg(test)]
115#[path = "route_inventory_tests.rs"]
116mod tests;