|
27 | 27 | CreateScheduleResponse, |
28 | 28 | DeleteScheduleRequest, |
29 | 29 | DeleteScheduleResponse, |
| 30 | + EventRecord, |
| 31 | + EventTraceResponse, |
30 | 32 | GetScheduleRequest, |
31 | 33 | GetScheduleResponse, |
32 | 34 | ListSchedulesRequest, |
33 | 35 | ListSchedulesResponse, |
34 | 36 | RebootAgentResponse, |
| 37 | + RecentTracesResponse, |
35 | 38 | StopAgentResponse, |
| 39 | + TopicListItem, |
36 | 40 | UpdateScheduleRequest, |
37 | 41 | UpdateScheduleResponse, |
38 | 42 | ) |
@@ -140,6 +144,47 @@ class PublishEventRequest(BaseModel): |
140 | 144 | ) |
141 | 145 |
|
142 | 146 |
|
| 147 | +class ListTopicsRequest(BaseModel): |
| 148 | + """Request payload for listing topics.""" |
| 149 | + |
| 150 | + namespace: str = Field( |
| 151 | + description="Namespace (required). Use the namespace from the agent's dispatch.yaml, or call list_namespaces to discover valid namespaces." |
| 152 | + ) |
| 153 | + |
| 154 | + |
| 155 | +class GetRecentEventsRequest(BaseModel): |
| 156 | + """Request payload for getting recent events.""" |
| 157 | + |
| 158 | + namespace: str = Field( |
| 159 | + description="Namespace (required). Use the namespace from the agent's dispatch.yaml, or call list_namespaces to discover valid namespaces." |
| 160 | + ) |
| 161 | + topic: str | None = Field(default=None, description="Optional topic filter") |
| 162 | + limit: int = Field( |
| 163 | + default=20, description="Max events to return (1-100)", ge=1, le=100 |
| 164 | + ) |
| 165 | + |
| 166 | + |
| 167 | +class GetEventTraceRequest(BaseModel): |
| 168 | + """Request payload for getting an event trace.""" |
| 169 | + |
| 170 | + trace_id: str = Field(description="Trace ID to look up") |
| 171 | + namespace: str = Field( |
| 172 | + description="Namespace (required). Use the namespace from the agent's dispatch.yaml, or call list_namespaces to discover valid namespaces." |
| 173 | + ) |
| 174 | + |
| 175 | + |
| 176 | +class GetRecentTracesRequest(BaseModel): |
| 177 | + """Request payload for getting recent traces.""" |
| 178 | + |
| 179 | + namespace: str = Field( |
| 180 | + description="Namespace (required). Use the namespace from the agent's dispatch.yaml, or call list_namespaces to discover valid namespaces." |
| 181 | + ) |
| 182 | + topic: str | None = Field(default=None, description="Optional topic filter") |
| 183 | + limit: int = Field( |
| 184 | + default=50, description="Max traces to return (1-100)", ge=1, le=100 |
| 185 | + ) |
| 186 | + |
| 187 | + |
143 | 188 | class GetAgentFunctionsRequest(BaseModel): |
144 | 189 | """Request payload for getting agent functions.""" |
145 | 190 |
|
@@ -1152,6 +1197,76 @@ async def publish_event(request: PublishEventRequest) -> PublishEventResponse: |
1152 | 1197 | result = client.publish_event(request.topic, request.payload, namespace=ns) |
1153 | 1198 | return PublishEventResponse(**result) |
1154 | 1199 |
|
| 1200 | + @mcp.tool() |
| 1201 | + async def list_topics(request: ListTopicsRequest) -> list[TopicListItem]: |
| 1202 | + """List all topics in a namespace. |
| 1203 | +
|
| 1204 | + Returns topics with their subscribed handlers, webhook configuration, |
| 1205 | + and schema information. |
| 1206 | +
|
| 1207 | + Args: |
| 1208 | + request: ListTopicsRequest with namespace |
| 1209 | +
|
| 1210 | + Returns: |
| 1211 | + List of TopicListItem with topic details and subscribers |
| 1212 | + """ |
| 1213 | + ns = _get_namespace(request.namespace) |
| 1214 | + return client.list_topics(namespace=ns) |
| 1215 | + |
| 1216 | + @mcp.tool() |
| 1217 | + async def get_recent_events( |
| 1218 | + request: GetRecentEventsRequest, |
| 1219 | + ) -> list[EventRecord]: |
| 1220 | + """Get recent events, optionally filtered by topic. |
| 1221 | +
|
| 1222 | + Args: |
| 1223 | + request: GetRecentEventsRequest with namespace, optional topic filter, and limit |
| 1224 | +
|
| 1225 | + Returns: |
| 1226 | + List of EventRecord with event details |
| 1227 | + """ |
| 1228 | + ns = _get_namespace(request.namespace) |
| 1229 | + return client.get_recent_events( |
| 1230 | + namespace=ns, topic=request.topic, limit=request.limit |
| 1231 | + ) |
| 1232 | + |
| 1233 | + @mcp.tool() |
| 1234 | + async def get_event_trace(request: GetEventTraceRequest) -> EventTraceResponse: |
| 1235 | + """Get the full event trace tree for a given trace ID. |
| 1236 | +
|
| 1237 | + Returns a tree-structured view of all events in the trace, enriched |
| 1238 | + with invocation status, LLM call summaries, and MCP tool calls. |
| 1239 | +
|
| 1240 | + Args: |
| 1241 | + request: GetEventTraceRequest with trace_id and namespace |
| 1242 | +
|
| 1243 | + Returns: |
| 1244 | + EventTraceResponse with trace_id, total_events, tree-structured events, and optional llm_summary |
| 1245 | + """ |
| 1246 | + ns = _get_namespace(request.namespace) |
| 1247 | + return client.get_event_trace(trace_id=request.trace_id, namespace=ns) |
| 1248 | + |
| 1249 | + @mcp.tool() |
| 1250 | + async def get_recent_traces( |
| 1251 | + request: GetRecentTracesRequest, |
| 1252 | + ) -> RecentTracesResponse: |
| 1253 | + """Get recent trace summaries for agent invocations. |
| 1254 | +
|
| 1255 | + Returns summaries of recent traces, including trigger type, involved |
| 1256 | + agents, and event counts. Useful for discovering trace IDs to inspect |
| 1257 | + with get_event_trace. |
| 1258 | +
|
| 1259 | + Args: |
| 1260 | + request: GetRecentTracesRequest with namespace, optional topic filter, and limit |
| 1261 | +
|
| 1262 | + Returns: |
| 1263 | + RecentTracesResponse with total_events, unique_traces, and list of TraceSummary |
| 1264 | + """ |
| 1265 | + ns = _get_namespace(request.namespace) |
| 1266 | + return client.get_recent_traces( |
| 1267 | + namespace=ns, topic=request.topic, limit=request.limit |
| 1268 | + ) |
| 1269 | + |
1155 | 1270 | @mcp.tool() |
1156 | 1271 | async def get_agent_functions( |
1157 | 1272 | request: GetAgentFunctionsRequest, |
|
0 commit comments