Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

1.1 KB
Raw Blame
<!DOCTYPE html>
<html>
<head>
<title>WebMCP registerTool</title>
<link rel="author" href="mailto:[email protected]">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
promise_test(async () => {
  const tool = {
    name: 'echo',
    description: 'echo input',
    inputSchema: {
      type: 'object',
      properties: {
        text: {
          description: 'Value to echo',
          type: 'string',
        },
      },
      required: ['text'],
    },
    execute: (obj) => obj.text,
    annotations: {
      readOnlyHint: 'true',
    },
  };

  const controller = new AbortController();
  await document.modelContext.registerTool(tool, { signal: controller.signal });
  controller.abort();
}, 'register and unregister script tool');

promise_test(async () => {
  await document.modelContext.registerTool({
    name: 'empty',
    description: 'empty',
    inputSchema: {
      toJSON: () => {
        return 'undefined';
      },
    },
    execute: () => {},
  });
}, "registerTool succeeds when inputSchema.toJSON() returns 'undefined'");
</script>
</body>
</html>