ticket-read
List and filter tickets for a given backlog topic. Filter by status or batch to view specific subsets of work items.
Instructions
Read-only access to backlog tickets - list and filter tickets for a backlog item
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| topic | Yes | Topic name (required) | |
| status | No | Filter by status | |
| batch | No | Filter by batch |
Implementation Reference
- src/backlog-ticket-read.ts:1-42 (handler)Primary tool handler for 'ticket-read'. Uses the @opencode-ai/plugin 'tool()' builder. Takes 'topic' (required), 'status' (optional enum), and 'batch' (optional) arguments. Calls 'listTodos' to fetch and filter todos, then formats output as a Markdown table. Returns a message if no todos found.
import { tool } from "@opencode-ai/plugin"; import { listTodos } from "../lib/backlog-ticket-shared"; import { format } from "../lib/markdown-formatter"; export default tool({ description: "Read-only access to backlog todos - list and filter todos for a backlog item", args: { topic: tool.schema .string() .describe("Backlog topic to read todos from"), status: tool.schema .enum(["pending", "in_progress", "completed", "cancelled"]) .optional() .describe("Filter todos by status"), batch: tool.schema .string() .optional() .describe("Filter todos by batch identifier"), }, async execute(args, context) { const { topic, status, batch } = args; // Call listTodos with filters const todos = listTodos(topic, { status, batch }); if (todos.length === 0) { return `No todos found for backlog: ${topic}`; } return format(todos, { columns: [ { key: 'id' }, { key: 'content' }, { key: 'status' }, { key: 'batch' }, { key: 'dependencies' } ], forceTable: true }); } }); - src/index.ts:384-394 (handler)Fallback handler function 'handleBacklogTodoRead' used in the MCP server's switch-case dispatch. Parses args, calls 'listTodos' with filters, and returns JSON-stringified results.
async function handleBacklogTodoRead(args: any) { const { topic, status, batch } = args; if (!topic) throw new Error("topic is required"); const filters: any = {}; if (status) filters.status = status; if (batch) filters.batch = batch; const todos = listTodos(topic, filters); return JSON.stringify(todos, null, 2); } - src/index.ts:875-896 (schema)Schema/registration of 'ticket-read' as an MCP tool definition. Defines 'inputSchema' with 'topic' (required string), 'status' (optional enum), and 'batch' (optional string properties.
{ name: "ticket-read", description: "Read-only access to backlog tickets - list and filter tickets for a backlog item", inputSchema: { type: "object", properties: { topic: { type: "string", description: "Topic name (required)", }, status: { type: "string", enum: ["pending", "in_progress", "completed", "cancelled"], description: "Filter by status", }, batch: { type: "string", description: "Filter by batch", }, }, required: ["topic"], }, - src/index.ts:1014-1016 (registration)Switch-case routing in the MCP request handler. Maps tool name 'ticket-read' to call 'handleBacklogTodoRead'.
case "ticket-read": result = await handleBacklogTodoRead(request.params.arguments); break; - lib/backlog-ticket-shared.ts:380-393 (helper)Helper function 'listTodos' shared across ticket tools. Reads todos from storage for a given topic, then optionally filters by status and/or batch.
export function listTodos(topic: string, filters?: { status?: string, batch?: string }): Todo[] { const data = readTodos(topic); let todos = data.todos; if (filters?.status) { todos = todos.filter(t => t.status === filters.status); } if (filters?.batch) { todos = todos.filter(t => t.batch === filters.batch); } return todos; }