PageSourceSearch

https://numbersprotocol.io/js/webmcp.js

js numbersprotocol.io collected 2026-10-01 10:32:13 UTC 4,348 bytes, 147 lines download raw bytes

1/**
2 * WebMCP (Web Model Context Protocol) — Tool registration for AI agents
3 * Spec: https://webmachinelearning.github.io/webmcp/
4 *
5 * Exposes Numbers Protocol capabilities as browser-discoverable tools
6 * for AI agents operating within compatible user agents.
7 */
8
9(function initWebMCP() {
10  if (!("modelContext" in navigator)) {
11    return;
12  }
13
14  // Tool 1: Search blog articles and use cases
15  navigator.modelContext.registerTool({
16    name: "search_articles",
17    title: "Search Numbers Protocol Articles",
18    description:
19      "Search blog posts and use-case articles about digital provenance, " +
20      "C2PA credentials, blockchain verification, and AI content authenticity. " +
21      "Returns article titles, URLs, excerpts, and publication dates.",
22    inputSchema: {
23      type: "object",
24      properties: {
25        query: {
26          type: "string",
27          description: "Search keywords (e.g., 'C2PA', 'AI provenance', 'content authenticity')",
28        },
29        category: {
30          type: "string",
31          enum: [
32            "technology",
33            "product",
34            "ecosystem",
35            "company",
36            "use-case",
37          ],
38          description: "Optional category filter",
39        },
40      },
41      required: ["query"],
42    },
43    annotations: {
44      readOnlyHint: true,
45      openWorldHint: false,
46    },
47    async execute(input) {
48      const response = await fetch("/sitemap.xml");
49      const text = await response.text();
50      const parser = new DOMParser();
51      const xml = parser.parseFromString(text, "application/xml");
52      const urls = Array.from(xml.querySelectorAll("url > loc"))
53        .map(function (el) {
54          return el.textContent;
55        })
56        .filter(function (url) {
57          return url.includes("/blog/") || url.includes("/use-case-article/");
58        })
59        .filter(function (url) {
60          return url.toLowerCase().includes(input.query.toLowerCase());
61        })
62        .slice(0, 10);
63
64      return {
65        content: [
66          {
67            type: "text",
68            text: JSON.stringify({
69              results: urls,
70              total: urls.length,
71              source: "https://numbersprotocol.io/blog",
72            }),
73          },
74        ],
75      };
76    },
77  });
78
79  // Tool 2: Get provenance information
80  navigator.modelContext.registerTool({
81    name: "get_provenance_info",
82    title: "Get Provenance Infrastructure Info",
83    description:
84      "Retrieve information about Numbers Protocol provenance infrastructure, " +
85      "including supported standards (C2PA, ERC-7053), products (Proof, CaptureApp), " +
86      "and integration options for content authenticity verification.",
87    inputSchema: {
88      type: "object",
89      properties: {
90        topic: {
91          type: "string",
92          enum: [
93            "overview",
94            "c2pa",
95            "products",
96            "api",
97            "innovation-program",
98          ],
99          description: "Topic area to retrieve information about",
100        },
101      },
102      required: ["topic"],
103    },
104    annotations: {
105      readOnlyHint: true,
106      openWorldHint: false,
107    },
108    async execute(input) {
109      const response = await fetch("/llms-full.txt");
110      const text = await response.text();
111      return {
112        content: [{ type: "text", text: text }],
113      };
114    },
115  });
116
117  // Tool 3: Check Innovation Program grant eligibility
118  navigator.modelContext.registerTool({
119    name: "check_grant_eligibility",
120    title: "Check Innovation Program Eligibility",
121    description:
122      "Check eligibility for Numbers Innovation Program 2.0 grants. " +
123      "Provides information about available tiers ($20-$200), requirements, " +
124      "and application process for AI agent developers.",
125    inputSchema: {
126      type: "object",
127      properties: {
128        tier: {
129          type: "string",
130          enum: ["explorer", "builder", "pioneer"],
131          description: "Grant tier to check eligibility for",
132        },
133      },
134    },
135    annotations: {
136      readOnlyHint: true,
137      openWorldHint: true,
138    },
139    async execute(input) {
140      const response = await fetch("/.well-known/agent-skills/check-eligibility.md");
141      const text = await response.text();
142      return {
143        content: [{ type: "text", text: text }],
144      };
145    },
146  });
147})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.