package chattools // The tool names, as the MCP server lists them. const ( ToolShowFile = "show_file" ToolShowImage = "show_image" ToolShowHTML = "show_html" ToolShowDiff = "show_diff" ToolShowRun = "show_run" ToolNotify = "notify" // ToolScheduleFollowup queues a prompt into the calling chat for later. ToolScheduleFollowup = "schedule_followup" ) // MaxHTMLBytes bounds one show_html document. A larger one is refused, never // truncated: a cut document would render as something the model did not write. const MaxHTMLBytes = 512 << 10 // The shown-file bounds: a file up to MaxSnapshotBytes is copied when shown, // and a web image up to MaxFetchedImageBytes is fetched by Pipelines. const ( MaxSnapshotBytes = 5 << 20 MaxFetchedImageBytes = 10 << 20 ) // The schedule_followup bounds. const ( MinFollowupMinutes = 1 MaxFollowupMinutes = 7 * 24 * 60 MaxPendingFollowups = 3 MaxFollowupTextBytes = 8 << 10 ) // IsTool reports whether name is one of the Pipelines tools. func IsTool(name string) bool { switch name { case ToolShowFile, ToolShowImage, ToolShowHTML, ToolShowDiff, ToolShowRun, ToolNotify, ToolScheduleFollowup: return true } return false } // Instructions is the MCP initialize instructions text. const Instructions = "These tools act on Pipelines, the app the operator reads this chat in, not on your workspace. " + "Use show_file / show_image instead of telling the operator a path to open, show_html for diagrams, charts or small visual views, " + "show_diff when the operator asks to see changes or a diff (for example before submitting a pull request), " + "and notify only when the operator should look at Pipelines now (it reaches their open Pipelines apps and their phone). " + "Use show_run to follow a pipeline run live in the chat, and schedule_followup to come back to this chat later (for example to check on a run). " + "Every show_* result names the shown item's id: pass it as replace to update that card instead of adding another. " + "Your thinking is not shown to the operator: before asking them a question (for example with AskUserQuestion), " + "write what you found and why you are asking as a normal message, because the question form shows only the question and its options." type toolDefinition struct { Name string `json:"name"` Title string `json:"title,omitempty"` Description string `json:"description"` InputSchema map[string]any `json:"inputSchema"` Annotations map[string]any `json:"annotations,omitempty"` } func stringProperty(description string) map[string]any { return map[string]any{"type": "string", "description": description} } func objectSchema(required []string, properties map[string]any) map[string]any { return map[string]any{"type": "object", "properties": properties, "required": required, "additionalProperties": false} } // replaceProperty is the optional id of an earlier shown item to update. func replaceProperty() map[string]any { return stringProperty("Optional id of an item you showed earlier in this chat (from that call's result): " + "the card is updated in place instead of a new one being added. It must be the same kind of item.") } // definitions is the tools/list result, in a fixed order. func definitions() []toolDefinition { return []toolDefinition{ { Name: ToolShowFile, Title: "Show a file in the chat", Description: "Show the operator an existing file from this machine directly in the Pipelines chat: images appear inline, " + "documents (PDF, Markdown, text, CSV, HTML, and others) as a preview card they can tap to open or download. " + "Use this instead of telling the operator a path to navigate to. The file must be inside the operator's home directory. " + "A relative path is resolved against the chat's working directory. " + "A file up to 5 MiB is copied when shown, so the card keeps showing that version; a larger one stays linked " + "and the card says when it changed or no longer exists. The result names the item's id for replace.", InputSchema: objectSchema([]string{"path"}, map[string]any{ "path": stringProperty("Absolute path, ~/path, or a path relative to the chat's working directory."), "title": stringProperty("Optional short caption shown above the file."), "replace": replaceProperty(), }), Annotations: map[string]any{"readOnlyHint": true, "openWorldHint": false}, }, { Name: ToolShowImage, Title: "Show an image in the chat", Description: "Show the operator an image inline in the Pipelines chat, from a file on this machine (inside the operator's home) " + "or from an https:// URL. Pipelines downloads a URL itself (public https hosts only, at most 10 MiB, image types only) " + "and keeps a copy, so the operator sees it even where the host refuses other sites; a failed download is reported " + "to you and nothing is shown. The result names the item's id for replace.", InputSchema: objectSchema([]string{"url_or_path"}, map[string]any{ "url_or_path": stringProperty("An https:// image URL, or a file path as for show_file."), "title": stringProperty("Optional short caption."), "alt": stringProperty("Optional description of the image for accessibility."), "replace": replaceProperty(), }), Annotations: map[string]any{"readOnlyHint": true}, }, { Name: ToolShowHTML, Title: "Show an HTML view in the chat", Description: "Render a self-contained HTML or SVG document inline in the Pipelines chat: diagrams, charts, tables, small visual views. " + "It is shown in a sandbox with no scripts, no network and no access to the app: use inline CSS and inline SVG, " + "
for expandable parts and CSS :hover for interaction; JavaScript does not run and external resources do not load. " + "The view follows the operator's light or dark theme (color-scheme and prefers-color-scheme): style for both with " + "@media (prefers-color-scheme: dark) or CSS system colors (Canvas, CanvasText), or set your own background and text colors; " + "unstyled text uses the theme's default colors. " + "The operator can open it full screen. At most 512 KiB. The result names the item's id: pass it as replace to update the view.", InputSchema: objectSchema([]string{"html"}, map[string]any{ "html": stringProperty("The complete HTML (or a bare ) document."), "title": stringProperty("Optional short caption."), "height_hint": map[string]any{"type": "integer", "description": "Optional preferred inline height in logical pixels (120-600)."}, "replace": replaceProperty(), }), Annotations: map[string]any{"readOnlyHint": true, "openWorldHint": false}, }, { Name: ToolShowDiff, Title: "Show a Git diff in the chat", Description: "Show the operator the changes in a Git repository on this machine as a diff card in the Pipelines chat: " + "every changed file with its added and removed lines, each opening the app's diff viewer. " + "Use it when the operator asks to see the diff or the changes, for example before a pull request is submitted. " + "Pipelines runs Git itself, so do not paste the diff. Without base it shows uncommitted work (staged, unstaged and untracked files) against HEAD. " + "With base (the pull request's target branch, such as main or origin/main) it shows everything since the branch left base, " + "which is what the pull request would contain, plus uncommitted work unless committed_only is true. " + "With head (a branch or commit, such as pipelines/run-123) it compares that revision instead of the working tree: " + "against base when given (everything since head left base), else against HEAD. paths limits the diff to those files, " + "directories or globs inside the repository. " + "The repository must be inside the operator's home directory. Very large diffs are shown partially and say so.", InputSchema: objectSchema([]string{}, map[string]any{ "path": stringProperty("Optional repository directory: absolute, ~/path, or relative to the chat's working directory. Defaults to the chat's working directory."), "base": stringProperty("Optional branch, tag or commit to compare against, such as main or origin/main. Omit to show uncommitted changes."), "head": stringProperty("Optional branch, tag or commit to show instead of the working tree, such as pipelines/run-123."), "paths": map[string]any{"type": "array", "items": map[string]any{"type": "string"}, "description": "Optional repository-relative files, directories or globs (such as internal/server or *.go) to limit the diff to; at most 50."}, "committed_only": map[string]any{"type": "boolean", "description": "Only with base: show the committed changes (base...HEAD) and leave out uncommitted work."}, "title": stringProperty("Optional short caption shown above the diff."), "replace": replaceProperty(), }), Annotations: map[string]any{"readOnlyHint": true, "openWorldHint": false}, }, { Name: ToolNotify, Title: "Notify the operator", Description: "Send a notification to the operator's open Pipelines apps (web, desktop) and their phone; it opens this chat when tapped. " + "Use it sparingly, for things they should know now (a long task finished, you are blocked on them). " + "Limited to 5 per minute per chat. Returns whether delivery was accepted.", InputSchema: objectSchema([]string{"title", "message"}, map[string]any{ "title": stringProperty("Short notification title (one line)."), "message": stringProperty("Notification text (one or two sentences)."), "priority": map[string]any{"type": "string", "enum": []string{"low", "default", "high"}, "description": "Optional priority; default is default."}, }), Annotations: map[string]any{"readOnlyHint": false, "destructiveHint": false, "openWorldHint": true}, }, { Name: ToolShowRun, Title: "Show a pipeline run in the chat", Description: "Show the operator a live card for a Pipelines run: its pipeline, title, status, current stage and duration, " + "kept current as the run progresses; tapping it opens the run. Use it after starting a run, or when the operator asks about one. " + "The result names the item's id for replace.", InputSchema: objectSchema([]string{"run_id"}, map[string]any{ "run_id": map[string]any{"type": "integer", "description": "The run's numeric id (as in `pipelines status ` or pipelines/run-)."}, "title": stringProperty("Optional short caption shown above the run."), "replace": replaceProperty(), }), Annotations: map[string]any{"readOnlyHint": true, "openWorldHint": false}, }, { Name: ToolScheduleFollowup, Title: "Schedule a follow-up in this chat", Description: "Queue a message to yourself in this chat, delivered as a new prompt at a later time (for example to check on a long run). " + "The operator sees it in the chat as a scheduled message from the agent and can remove it. " + "Give at (an RFC 3339 time) or after_minutes, between 1 minute and 7 days from now. At most 3 follow-ups can be pending per chat. " + "It is delivered when the chat is free at that time, so do not wait for it in the current turn.", InputSchema: objectSchema([]string{"message"}, map[string]any{ "message": stringProperty("What the follow-up prompt should say: enough for you to know what to do then."), "at": stringProperty("When to deliver it, as an RFC 3339 time such as 2026-05-01T09:30:00Z. Give this or after_minutes."), "after_minutes": map[string]any{"type": "integer", "description": "Minutes from now to deliver it (1-10080). Give this or at."}, }), Annotations: map[string]any{"readOnlyHint": false, "destructiveHint": false, "openWorldHint": false}, }, } }