File size: 8,426 Bytes
6a7089a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package mcp

import "github.com/mark3labs/mcp-go/mcp"

// allTools returns every MCP tool exposed by the PinchTab MCP server.
func allTools() []mcp.Tool {
	return []mcp.Tool{
		// ── Navigation ──────────────────────────────────────────────
		mcp.NewTool("pinchtab_navigate",
			mcp.WithDescription("Navigate to a URL in the browser"),
			mcp.WithString("url", mcp.Required(), mcp.Description("The URL to navigate to")),
			mcp.WithString("tabId", mcp.Description("Target tab ID (optional, uses current tab if empty)")),
		),
		mcp.NewTool("pinchtab_snapshot",
			mcp.WithDescription("Get an accessibility tree snapshot of the current page"),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
			mcp.WithBoolean("interactive", mcp.Description("Only interactive elements (buttons, links, inputs)")),
			mcp.WithBoolean("compact", mcp.Description("Compact format (most token-efficient)")),
			mcp.WithBoolean("diff", mcp.Description("Only changes since last snapshot")),
			mcp.WithString("selector", mcp.Description("Unified selector to scope the snapshot (CSS, XPath, text, or ref)")),
		),
		mcp.NewTool("pinchtab_screenshot",
			mcp.WithDescription("Take a screenshot of the current page"),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
			mcp.WithString("format", mcp.Description("Image format: 'jpeg' (default) or 'png'")),
			mcp.WithNumber("quality", mcp.Description("JPEG quality 0-100 (only for JPEG format)")),
		),
		mcp.NewTool("pinchtab_get_text",
			mcp.WithDescription("Extract readable text content from the current page"),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
			mcp.WithBoolean("raw", mcp.Description("Return raw text without formatting")),
		),

		// ── Interaction ─────────────────────────────────────────────
		mcp.NewTool("pinchtab_click",
			mcp.WithDescription("Click an element by selector (ref from snapshot e.g. 'e5', CSS e.g. 'css:#btn', XPath e.g. 'xpath://button', text e.g. 'text:Submit', or semantic e.g. 'find:login button')"),
			mcp.WithString("selector", mcp.Required(), mcp.Description("Unified selector: ref (e.g. 'e5'), CSS ('css:#btn' or '#btn'), XPath ('xpath://button'), text ('text:Submit'), or semantic ('find:login button')")),
			mcp.WithString("ref", mcp.Description("(deprecated) Element ref from snapshot β€” use 'selector' instead")),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
		),
		mcp.NewTool("pinchtab_type",
			mcp.WithDescription("Type text into an input element"),
			mcp.WithString("selector", mcp.Required(), mcp.Description("Unified selector: ref (e.g. 'e5'), CSS, XPath, text, or semantic")),
			mcp.WithString("ref", mcp.Description("(deprecated) Element ref from snapshot β€” use 'selector' instead")),
			mcp.WithString("text", mcp.Required(), mcp.Description("Text to type")),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
		),
		mcp.NewTool("pinchtab_press",
			mcp.WithDescription("Press a keyboard key (Enter, Tab, Escape, etc.)"),
			mcp.WithString("key", mcp.Required(), mcp.Description("Key to press (e.g., 'Enter', 'Tab', 'Escape')")),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
		),
		mcp.NewTool("pinchtab_hover",
			mcp.WithDescription("Hover over an element"),
			mcp.WithString("selector", mcp.Required(), mcp.Description("Unified selector: ref (e.g. 'e5'), CSS, XPath, text, or semantic")),
			mcp.WithString("ref", mcp.Description("(deprecated) Element ref from snapshot β€” use 'selector' instead")),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
		),
		mcp.NewTool("pinchtab_focus",
			mcp.WithDescription("Focus an element"),
			mcp.WithString("selector", mcp.Required(), mcp.Description("Unified selector: ref (e.g. 'e5'), CSS, XPath, text, or semantic")),
			mcp.WithString("ref", mcp.Description("(deprecated) Element ref from snapshot β€” use 'selector' instead")),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
		),
		mcp.NewTool("pinchtab_select",
			mcp.WithDescription("Select a dropdown option by value"),
			mcp.WithString("selector", mcp.Required(), mcp.Description("Unified selector for the select element")),
			mcp.WithString("ref", mcp.Description("(deprecated) Element ref from snapshot β€” use 'selector' instead")),
			mcp.WithString("value", mcp.Required(), mcp.Description("Option value to select")),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
		),
		mcp.NewTool("pinchtab_scroll",
			mcp.WithDescription("Scroll the page or an element"),
			mcp.WithString("selector", mcp.Description("Unified selector for element to scroll (omit for page scroll)")),
			mcp.WithString("ref", mcp.Description("(deprecated) Element ref to scroll β€” use 'selector' instead")),
			mcp.WithNumber("pixels", mcp.Description("Number of pixels to scroll (positive=down, negative=up)")),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
		),
		mcp.NewTool("pinchtab_fill",
			mcp.WithDescription("Fill an input field directly via JavaScript dispatch"),
			mcp.WithString("selector", mcp.Required(), mcp.Description("Unified selector: ref (e.g. 'e5'), CSS, XPath, text, or semantic")),
			mcp.WithString("ref", mcp.Description("(deprecated) Element ref β€” use 'selector' instead")),
			mcp.WithString("value", mcp.Required(), mcp.Description("Value to fill")),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
		),

		// ── Content ─────────────────────────────────────────────────
		mcp.NewTool("pinchtab_eval",
			mcp.WithDescription("Execute JavaScript in the browser and return the result"),
			mcp.WithString("expression", mcp.Required(), mcp.Description("JavaScript expression to evaluate")),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
		),
		mcp.NewTool("pinchtab_pdf",
			mcp.WithDescription("Export the current page as a PDF (returns base64-encoded PDF)"),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
			mcp.WithBoolean("landscape", mcp.Description("Landscape orientation")),
			mcp.WithNumber("scale", mcp.Description("Print scale 0.1-2.0 (default: 1.0)")),
			mcp.WithString("pageRanges", mcp.Description("Pages to export (e.g., '1-3,5')")),
		),
		mcp.NewTool("pinchtab_find",
			mcp.WithDescription("Find elements by text content or CSS selector"),
			mcp.WithString("query", mcp.Required(), mcp.Description("Text or CSS selector to search for")),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
		),

		// ── Tab Management ──────────────────────────────────────────
		mcp.NewTool("pinchtab_list_tabs",
			mcp.WithDescription("List all open browser tabs"),
		),
		mcp.NewTool("pinchtab_close_tab",
			mcp.WithDescription("Close a browser tab"),
			mcp.WithString("tabId", mcp.Description("ID of the tab to close")),
		),
		mcp.NewTool("pinchtab_health",
			mcp.WithDescription("Check PinchTab server health status"),
		),
		mcp.NewTool("pinchtab_cookies",
			mcp.WithDescription("Get cookies for the current page"),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
		),
		mcp.NewTool("pinchtab_connect_profile",
			mcp.WithDescription("Get the user-facing connect URL and instance status for a profile"),
			mcp.WithString("profile", mcp.Required(), mcp.Description("Profile name or profile ID")),
		),

		// ── Utility ─────────────────────────────────────────────────
		mcp.NewTool("pinchtab_wait",
			mcp.WithDescription("Wait for a specified number of milliseconds"),
			mcp.WithNumber("ms", mcp.Required(), mcp.Description("Milliseconds to wait (max 30000)")),
		),
		mcp.NewTool("pinchtab_wait_for_selector",
			mcp.WithDescription("Wait for an element matching a selector to appear on the page"),
			mcp.WithString("selector", mcp.Required(), mcp.Description("Unified selector to wait for (CSS, XPath, text, or ref)")),
			mcp.WithNumber("timeout", mcp.Description("Timeout in milliseconds (default: 10000, max: 30000)")),
			mcp.WithString("tabId", mcp.Description("Target tab ID")),
		),
	}
}