Skip to content

Commit a498cc1

Browse files
committed
feat(tools): implement browser tools registration
1 parent 7de8529 commit a498cc1

File tree

1 file changed

+201
-0
lines changed

1 file changed

+201
-0
lines changed

src/tools.ts

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
import { Tool } from "@modelcontextprotocol/sdk/types.js";
2+
3+
export const BROWSER_TOOLS = [
4+
"browser_navigate",
5+
"browser_screenshot",
6+
"browser_click",
7+
"browser_fill",
8+
"browser_select",
9+
"browser_hover",
10+
"browser_evaluate"
11+
];
12+
13+
export const API_TOOLS = [
14+
"api_get",
15+
"api_post",
16+
"api_put",
17+
"api_patch",
18+
"api_delete"
19+
];
20+
21+
export function registerTools(): Tool[] {
22+
return [
23+
{
24+
name: "browser_navigate",
25+
description: "Navigate to a specific URL",
26+
inputSchema: {
27+
type: "object",
28+
properties: {
29+
url: { type: "string", description: "URL to navigate to" },
30+
timeout: { type: "number", description: "Navigation timeout in milliseconds" },
31+
waitUntil: {
32+
type: "string",
33+
description: "Navigation wait criteria",
34+
enum: ["load", "domcontentloaded", "networkidle", "commit"]
35+
}
36+
},
37+
required: ["url"]
38+
}
39+
},
40+
{
41+
name: "browser_screenshot",
42+
description: "Capture a screenshot of the current page or a specific element",
43+
inputSchema: {
44+
type: "object",
45+
properties: {
46+
name: { type: "string", description: "Identifier for the screenshot" },
47+
selector: { type: "string", description: "CSS selector for element to capture" },
48+
fullPage: { type: "boolean", description: "Capture full page height" },
49+
mask: {
50+
type: "array",
51+
description: "Selectors for elements to mask",
52+
items: { type: "string" }
53+
},
54+
savePath: { type: "string", description: "Path to save screenshot (default: user's Downloads folder)" }
55+
},
56+
required: ["name"]
57+
}
58+
},
59+
{
60+
name: "browser_click",
61+
description: "Click an element on the page",
62+
inputSchema: {
63+
type: "object",
64+
properties: {
65+
selector: { type: "string", description: "CSS selector for element to click" }
66+
},
67+
required: ["selector"]
68+
}
69+
},
70+
{
71+
name: "browser_fill",
72+
description: "Fill a form input with text",
73+
inputSchema: {
74+
type: "object",
75+
properties: {
76+
selector: { type: "string", description: "CSS selector for input field" },
77+
value: { type: "string", description: "Text to enter in the field" }
78+
},
79+
required: ["selector", "value"]
80+
}
81+
},
82+
{
83+
name: "browser_select",
84+
description: "Select an option from a dropdown menu",
85+
inputSchema: {
86+
type: "object",
87+
properties: {
88+
selector: { type: "string", description: "CSS selector for select element" },
89+
value: { type: "string", description: "Value or label to select" }
90+
},
91+
required: ["selector", "value"]
92+
}
93+
},
94+
{
95+
name: "browser_hover",
96+
description: "Hover over an element on the page",
97+
inputSchema: {
98+
type: "object",
99+
properties: {
100+
selector: { type: "string", description: "CSS selector for element to hover over" }
101+
},
102+
required: ["selector"]
103+
}
104+
},
105+
{
106+
name: "browser_evaluate",
107+
description: "Execute JavaScript in the browser context",
108+
inputSchema: {
109+
type: "object",
110+
properties: {
111+
script: { type: "string", description: "JavaScript code to execute" }
112+
},
113+
required: ["script"]
114+
}
115+
},
116+
117+
{
118+
name: "api_get",
119+
description: "Perform a GET request to an API endpoint",
120+
inputSchema: {
121+
type: "object",
122+
properties: {
123+
url: { type: "string", description: "API endpoint URL" },
124+
headers: {
125+
type: "object",
126+
description: "Request headers",
127+
additionalProperties: { type: "string" }
128+
}
129+
},
130+
required: ["url"]
131+
}
132+
},
133+
{
134+
name: "api_post",
135+
description: "Perform a POST request to an API endpoint",
136+
inputSchema: {
137+
type: "object",
138+
properties: {
139+
url: { type: "string", description: "API endpoint URL" },
140+
data: { type: "string", description: "Request body data (JSON string)" },
141+
headers: {
142+
type: "object",
143+
description: "Request headers",
144+
additionalProperties: { type: "string" }
145+
}
146+
},
147+
required: ["url", "data"]
148+
}
149+
},
150+
{
151+
name: "api_put",
152+
description: "Perform a PUT request to an API endpoint",
153+
inputSchema: {
154+
type: "object",
155+
properties: {
156+
url: { type: "string", description: "API endpoint URL" },
157+
data: { type: "string", description: "Request body data (JSON string)" },
158+
headers: {
159+
type: "object",
160+
description: "Request headers",
161+
additionalProperties: { type: "string" }
162+
}
163+
},
164+
required: ["url", "data"]
165+
}
166+
},
167+
{
168+
name: "api_patch",
169+
description: "Perform a PATCH request to an API endpoint",
170+
inputSchema: {
171+
type: "object",
172+
properties: {
173+
url: { type: "string", description: "API endpoint URL" },
174+
data: { type: "string", description: "Request body data (JSON string)" },
175+
headers: {
176+
type: "object",
177+
description: "Request headers",
178+
additionalProperties: { type: "string" }
179+
}
180+
},
181+
required: ["url", "data"]
182+
}
183+
},
184+
{
185+
name: "api_delete",
186+
description: "Perform a DELETE request to an API endpoint",
187+
inputSchema: {
188+
type: "object",
189+
properties: {
190+
url: { type: "string", description: "API endpoint URL" },
191+
headers: {
192+
type: "object",
193+
description: "Request headers",
194+
additionalProperties: { type: "string" }
195+
}
196+
},
197+
required: ["url"]
198+
}
199+
}
200+
];
201+
}

0 commit comments

Comments
 (0)