package chattools // The tool names, as the MCP server lists them. const ( ToolShowFile = "show_file" ToolShowImage = "show_image" ToolShowHTML = "show_html" ToolShowDiff = "show_diff" ToolNotify = "notify" ) // 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 // IsTool reports whether name is one of the Pipelines tools. func IsTool(name string) bool { switch name { case ToolShowFile, ToolShowImage, ToolShowHTML, ToolShowDiff, ToolNotify: 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 their phone now." 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} } // 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.", 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."), }), 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. The URL is loaded by the operator's device without cookies.", 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."), }), 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 operator can open it full screen. At most 512 KiB.", 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)."}, }), 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. " + "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."), "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."), }), Annotations: map[string]any{"readOnlyHint": true, "openWorldHint": false}, }, { Name: ToolNotify, Title: "Notify the operator's phone", Description: "Send a push notification to the operator's phone that 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}, }, } }