cctether 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/mcp.js +16 -0
  3. package/src/tools.js +28 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cctether",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Let Claude Code use your browser over your own connection — no third-party relay.",
5
5
  "keywords": [
6
6
  "claude-code",
package/src/mcp.js CHANGED
@@ -32,6 +32,16 @@ export function createMcpSession({ write, browser, version, log = () => {}, unav
32
32
  const reply = (id, result) => write(JSON.stringify({ jsonrpc: '2.0', id, result }));
33
33
  const replyError = (id, code, message) => write(JSON.stringify({ jsonrpc: '2.0', id: id ?? null, error: { code, message } }));
34
34
 
35
+ // The tool list is this server's, so an extension older than the server may not know a tool
36
+ // (e.g. while a new version waits for Chrome Web Store review). It says so itself; no version
37
+ // comparison here.
38
+ function outdatedExtension(name) {
39
+ const ext = browser?.status?.()?.info?.extension || 'unknown';
40
+ return `${name} is not supported by the connected cctether browser extension (version ${ext}; this server is ${version}). `
41
+ + 'The extension is older than the server: ask the user to update it (chrome://extensions → Developer mode → Update). '
42
+ + 'If the Chrome Web Store does not have the new version yet, this tool can\'t be used for now.';
43
+ }
44
+
35
45
  async function callTool(params) {
36
46
  const name = params?.name;
37
47
  const tool = TOOLS.find((t) => t.name === name);
@@ -42,6 +52,7 @@ export function createMcpSession({ write, browser, version, log = () => {}, unav
42
52
  if (unavailable) return { result: errorResult(unavailable) };
43
53
  try {
44
54
  const r = await browser.call(name, args, toolTimeoutMs(name, args));
55
+ if (!r.ok && isUnknownToolAnswer(r.error)) return { result: errorResult(outdatedExtension(name)) };
45
56
  if (!r.ok) return { result: errorResult(r.error.message) };
46
57
  return { result: { content: sanitizeContent(r.data?.content) } };
47
58
  } catch (e) {
@@ -108,6 +119,11 @@ function errorResult(text) {
108
119
  return { content: [{ type: 'text', text }], isError: true };
109
120
  }
110
121
 
122
+ /** What an extension answers for a tool it doesn't have (extension/background/app.js onCall). */
123
+ function isUnknownToolAnswer(error) {
124
+ return error?.code === 'bad_args' && typeof error.message === 'string' && error.message.startsWith('Unknown tool "');
125
+ }
126
+
111
127
  const IMAGE_TYPES = new Set(['image/jpeg', 'image/png', 'image/webp']);
112
128
 
113
129
  /** Pass through only well-formed text and image items. */
package/src/tools.js CHANGED
@@ -113,6 +113,34 @@ export const TOOLS = [
113
113
  },
114
114
  annotations: READ,
115
115
  },
116
+ {
117
+ name: 'resize_viewport',
118
+ title: 'Resize viewport',
119
+ description: 'Resize a tab\'s viewport (CSS px) without resizing the browser window, e.g. width 390 to check a narrow layout. A desktop viewport, not mobile-device emulation. An omitted dimension keeps its current size. reset: true clears the override; it also ends when cctether detaches from the tab (5 min without tool calls, pause).',
120
+ inputSchema: {
121
+ type: 'object',
122
+ properties: {
123
+ width: { type: 'integer', minimum: 200, maximum: 3840 },
124
+ height: { type: 'integer', minimum: 200, maximum: 3840 },
125
+ reset: { type: 'boolean', description: 'Back to the real size.' },
126
+ tab,
127
+ },
128
+ additionalProperties: false,
129
+ },
130
+ annotations: ACT,
131
+ },
132
+ {
133
+ name: 'set_color_scheme',
134
+ title: 'Set color scheme',
135
+ description: 'Make a tab see a dark or light color scheme (the prefers-color-scheme media feature), e.g. to check a page\'s dark mode, without changing the browser\'s own setting. It does not operate a site\'s own theme switch or change a theme the site saved. "system" removes the override; it also ends when cctether detaches from the tab (5 min without tool calls, pause).',
136
+ inputSchema: {
137
+ type: 'object',
138
+ properties: { scheme: { type: 'string', enum: ['dark', 'light', 'system'] }, tab },
139
+ required: ['scheme'],
140
+ additionalProperties: false,
141
+ },
142
+ annotations: ACT,
143
+ },
116
144
  {
117
145
  name: 'click',
118
146
  title: 'Click',