mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-15 04:18:19 +00:00
fix(browser): cap click and key repeat counts in MCP (#1367)
* fix(browser): cap click and key repeat counts in MCP * style: apply prettier formatting
This commit is contained in:
1 parent
8b3ba5532e
commit
c322829f44
3 files changed
+59
-3
No files matched your search
@@ -722,6 +722,47 @@ describe('ccs-browser MCP server - navigation and query', () => {
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
it('rejects excessive clickCount and repeat values', async () => {
|
||||
const responses = await runMcpRequests(
|
||||
[{ id: 'page-1', title: 'Limits Page', currentUrl: 'https://example.com/' }],
|
||||
[
|
||||
{
|
||||
jsonrpc: '2.0',
|
||||
id: 713,
|
||||
method: 'tools/call',
|
||||
params: {
|
||||
name: 'browser_click',
|
||||
arguments: {
|
||||
selector: '#submit',
|
||||
clickCount: 26,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
jsonrpc: '2.0',
|
||||
id: 714,
|
||||
method: 'tools/call',
|
||||
params: {
|
||||
name: 'browser_press_key',
|
||||
arguments: {
|
||||
key: 'k',
|
||||
repeat: 26,
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
const clickResponse = responses.find((message) => message.id === 713);
|
||||
expect((clickResponse?.result as { isError?: boolean }).isError).toBe(true);
|
||||
expect(getResponseText(clickResponse)).toContain('clickCount must be less than or equal to 25');
|
||||
|
||||
const keyResponse = responses.find((message) => message.id === 714);
|
||||
expect((keyResponse?.result as { isError?: boolean }).isError).toBe(true);
|
||||
expect(getResponseText(keyResponse)).toContain('repeat must be less than or equal to 25');
|
||||
});
|
||||
|
||||
it('scrolls an element into view with browser_scroll', async () => {
|
||||
const responses = await runMcpRequests(
|
||||
[
|
||||
|
||||
@@ -79,11 +79,17 @@ describe('ccs-browser MCP server - session and interception', () => {
|
||||
expect(clickTool?.inputSchema?.properties?.clickCount).toMatchObject({
|
||||
type: 'integer',
|
||||
minimum: 1,
|
||||
maximum: 25,
|
||||
});
|
||||
|
||||
const keyTool = tools.find((tool) => tool.name === 'browser_press_key');
|
||||
expect(keyTool?.inputSchema?.properties?.key).toMatchObject({ type: 'string' });
|
||||
expect(keyTool?.inputSchema?.properties?.modifiers).toMatchObject({ type: 'array' });
|
||||
expect(keyTool?.inputSchema?.properties?.repeat).toMatchObject({
|
||||
type: 'integer',
|
||||
minimum: 1,
|
||||
maximum: 25,
|
||||
});
|
||||
|
||||
const scrollTool = tools.find((tool) => tool.name === 'browser_scroll');
|
||||
expect(scrollTool?.inputSchema?.properties?.deltaX).toMatchObject({ type: 'number' });
|
||||
|
||||
Reference in new issue
Block a user