cc0-library-mcp 0.1.0 → 0.2.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.
package/dist/search.js CHANGED
@@ -10,6 +10,14 @@ import { getMet, searchMet } from "./providers/met.js";
10
10
  import { getCommons, searchCommons } from "./providers/commons.js";
11
11
  import { getArchive, searchArchive } from "./providers/archive.js";
12
12
  import { getSketchfab, searchSketchfab } from "./providers/sketchfab.js";
13
+ import { getWpPhoto, searchWpPhotos } from "./providers/wpphotos.js";
14
+ import { getINaturalist, searchINaturalist } from "./providers/inaturalist.js";
15
+ import { getGbif, searchGbif } from "./providers/gbif.js";
16
+ import { getPhylopic, searchPhylopic } from "./providers/phylopic.js";
17
+ import { getIconify, searchIconify } from "./providers/iconify.js";
18
+ import { getZenodo, searchZenodo } from "./providers/zenodo.js";
19
+ import { getGithub, getHuggingface, searchGithub, searchHuggingface } from "./providers/collections.js";
20
+ import { getBlenderkit, searchBlenderkit } from "./providers/blenderkit.js";
13
21
  /**
14
22
  * Runs one search across the providers that serve `kind`. With kind "any",
15
23
  * results from each provider are interleaved so one provider cannot crowd
@@ -39,6 +47,26 @@ export async function search(fetchImpl, query, kind, limit, page, options = {})
39
47
  }
40
48
  if (kind === "model" || kind === "any")
41
49
  all.push({ name: "sketchfab", run: () => searchSketchfab(fetchImpl, params) });
50
+ if (kind === "image" || kind === "any") {
51
+ all.push({ name: "wpphotos", run: () => searchWpPhotos(fetchImpl, params) });
52
+ all.push({ name: "inaturalist", run: () => searchINaturalist(fetchImpl, params) });
53
+ all.push({ name: "gbif", run: () => searchGbif(fetchImpl, params) });
54
+ all.push({ name: "phylopic", run: () => searchPhylopic(fetchImpl, params) });
55
+ all.push({ name: "iconify", run: () => searchIconify(fetchImpl, params) });
56
+ }
57
+ if (kind === "image" || kind === "video" || kind === "any") {
58
+ const k = kind === "any" ? "all" : kind;
59
+ all.push({ name: "zenodo", run: () => searchZenodo(fetchImpl, k, params) });
60
+ }
61
+ if (kind === "hdri" || kind === "texture" || kind === "model" || kind === "any") {
62
+ const k = kind === "any" ? "all" : kind;
63
+ all.push({ name: "blenderkit", run: () => searchBlenderkit(fetchImpl, k, params) });
64
+ }
65
+ // Collections only on request: GitHub allows 10 unauthenticated searches a minute.
66
+ if (kind === "collection") {
67
+ all.push({ name: "github", run: () => searchGithub(fetchImpl, params) });
68
+ all.push({ name: "huggingface", run: () => searchHuggingface(fetchImpl, params) });
69
+ }
42
70
  const skip = new Set(options.skip ?? []);
43
71
  const run = all.filter((j) => !skip.has(j.name.split(":")[0]));
44
72
  const settled = await Promise.allSettled(run.map((j) => j.run()));
@@ -68,13 +96,17 @@ export function interleave(lists) {
68
96
  /**
69
97
  * Resolves ids produced by `search`: `openverse:image:<uuid>`, `openverse:audio:<uuid>`,
70
98
  * `polyhaven:<slug>`, `ambientcg:<assetId>`, `cleveland:<number>`, `met:<number>`,
71
- * `commons:<pageid>`, `archive:<identifier>`, `sketchfab:<uid>`.
99
+ * `commons:<pageid>`, `archive:<identifier>`, `sketchfab:<uid>`, `wpphotos:<number>`,
100
+ * `inaturalist:<number>`, `gbif:<number>`, `phylopic:<uuid>`, `iconify:<set>:<icon>`, `zenodo:<number>`,
101
+ * `github:<owner>/<repo>`, `huggingface:<owner>/<dataset>`, `blenderkit:<uuid>`.
72
102
  */
73
103
  export async function getAsset(fetchImpl, id) {
74
104
  const parts = id.split(":");
75
105
  const [provider, a, b] = parts;
76
106
  if (parts.length === 3 && provider === "openverse" && (a === "image" || a === "audio") && b)
77
107
  return getOpenverse(fetchImpl, a, b);
108
+ if (parts.length === 3 && provider === "iconify" && a && b)
109
+ return getIconify(fetchImpl, a, b);
78
110
  if (parts.length !== 2 || !a)
79
111
  return null;
80
112
  if (provider === "polyhaven")
@@ -91,5 +123,21 @@ export async function getAsset(fetchImpl, id) {
91
123
  return getArchive(fetchImpl, a);
92
124
  if (provider === "sketchfab")
93
125
  return getSketchfab(fetchImpl, a);
126
+ if (provider === "wpphotos")
127
+ return getWpPhoto(fetchImpl, a);
128
+ if (provider === "inaturalist")
129
+ return getINaturalist(fetchImpl, a);
130
+ if (provider === "gbif")
131
+ return getGbif(fetchImpl, a);
132
+ if (provider === "phylopic")
133
+ return getPhylopic(fetchImpl, a);
134
+ if (provider === "zenodo")
135
+ return getZenodo(fetchImpl, a);
136
+ if (provider === "github")
137
+ return getGithub(fetchImpl, a);
138
+ if (provider === "huggingface")
139
+ return getHuggingface(fetchImpl, a);
140
+ if (provider === "blenderkit")
141
+ return getBlenderkit(fetchImpl, a);
94
142
  return null;
95
143
  }
package/dist/server.js CHANGED
@@ -2,62 +2,171 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { z } from "zod";
3
3
  import { defaultFetch } from "./http.js";
4
4
  import { getAsset, loadCatalog, search } from "./library.js";
5
- import { ASSET_KINDS } from "./types.js";
5
+ import { ASSET_KINDS, CATALOG_KINDS, PROVIDER_IDS } from "./types.js";
6
6
  /** Poly Haven textures can list 100+ map/resolution/format files; keep replies readable. */
7
7
  const MAX_FILES_IN_REPLY = 60;
8
- const json = (value) => ({ content: [{ type: "text", text: JSON.stringify(value, null, 2) }] });
8
+ const KIND_HELP = "Asset type. image: Openverse, Wikimedia Commons, Internet Archive, WordPress Photo Directory, iNaturalist and GBIF " +
9
+ "(nature photos), PhyloPic (organism silhouettes; search by taxon name), Iconify (CC0 icon sets), Zenodo (research figures). " +
10
+ "audio: Openverse, Commons, Internet Archive. video: Commons, Internet Archive, Zenodo. " +
11
+ "hdri, texture: Poly Haven, ambientCG, BlenderKit. model: Poly Haven, ambientCG, Sketchfab, BlenderKit. " +
12
+ "artwork: public-domain works from the Cleveland Museum of Art and The Met. " +
13
+ "collection: whole CC0 GitHub repositories and Hugging Face datasets (only when asked for; not part of 'any'). " +
14
+ "any (default): every kind except collection, interleaved.";
15
+ // ---------- output schemas: every returned field is documented here ----------
16
+ const licenseEvidenceSchema = z
17
+ .object({
18
+ license: z.literal("CC0-1.0").describe("Always CC0-1.0; non-CC0 items are never returned"),
19
+ licenseUrl: z.string().describe("CC0 1.0 deed URL"),
20
+ method: z
21
+ .enum(["per-item-license-field", "whole-library-cc0"])
22
+ .describe("per-item-license-field: the item's own record says CC0; whole-library-cc0: the site publishes everything as CC0"),
23
+ source: z.string().describe("The exact field or policy page the check used, with its URL"),
24
+ declaredBy: z
25
+ .enum(["library", "institution", "uploader"])
26
+ .describe("Who declared CC0. library = the studio that made it; institution = the museum holding the work; " +
27
+ "uploader = a site user, unreviewed and sometimes wrong (warn the user to verify ownership)"),
28
+ })
29
+ .describe("How CC0 status was verified for this item");
30
+ const assetShape = {
31
+ id: z.string().describe("Stable id to pass to get_asset, e.g. 'polyhaven:brown_planks_03' or 'met:436535'"),
32
+ kind: z.enum(ASSET_KINDS).describe("Asset type"),
33
+ title: z.string().describe("Title at the source"),
34
+ creator: z.string().nullable().describe("Creator or uploader name, null if the source gives none"),
35
+ landingUrl: z.string().describe("Human-facing page at the source; link this when showing the item"),
36
+ fileUrl: z.string().nullable().describe("Direct file or preview URL when the search response includes one; use get_asset for all files"),
37
+ thumbnailUrl: z.string().nullable().describe("Small preview image URL, null for audio and some items"),
38
+ tags: z.array(z.string()).describe("Up to 20 source tags or categories"),
39
+ provider: z.enum(PROVIDER_IDS).describe("API that served the item"),
40
+ origin: z.string().describe("Site the item originally came from (e.g. flickr, freesound, metmuseum.org)"),
41
+ licenseEvidence: licenseEvidenceSchema,
42
+ servedBy: z.string().describe("Credit line required by the serving API's terms; show it next to results"),
43
+ };
44
+ const fileSchema = z.object({
45
+ label: z.string().describe("Variant, e.g. '2K-JPG (zip)', 'hdri / 4k / exr', 'primary'"),
46
+ url: z.string().describe("Direct download URL (Sketchfab: model page, login required)"),
47
+ sizeBytes: z.number().nullable().describe("File size in bytes when the source reports it"),
48
+ });
49
+ const nameReason = z.object({
50
+ name: z.string(),
51
+ url: z.string().describe("Site URL"),
52
+ reason: z.string().describe("Why it is listed here"),
53
+ });
54
+ const searchOutput = {
55
+ query: z.string().describe("Query as received"),
56
+ kind: z.enum([...ASSET_KINDS, "any"]).describe("Kind as received"),
57
+ page: z.number().describe("Page as received"),
58
+ assets: z.array(z.object(assetShape)).describe("CC0 results, at most `limit`; may be fewer when sources drop non-CC0 items"),
59
+ totals: z.record(z.string(), z.number()).describe("Upstream match count per source job (before CC0 re-checks); useful to decide whether to page"),
60
+ errors: z.array(z.string()).describe("Sources that failed this time, e.g. 'met: The Met returned HTTP 503'; other sources still returned results"),
61
+ };
62
+ const getOutput = {
63
+ ...assetShape,
64
+ description: z.string().nullable().describe("Source description or credit line, if any"),
65
+ files: z.array(fileSchema).describe(`Downloadable files, at most ${MAX_FILES_IN_REPLY}; empty when the source offers none`),
66
+ filesNote: z.string().optional().describe("Present when files were truncated"),
67
+ };
68
+ const listOutput = {
69
+ sources: z
70
+ .array(z.object({
71
+ id: z.string(),
72
+ name: z.string(),
73
+ url: z.string().describe("Where to browse the source"),
74
+ kinds: z.array(z.enum(CATALOG_KINDS)),
75
+ scope: z.enum(["whole-library", "filter-only"]).describe("whole-library: everything is CC0; filter-only: only CC0-labeled items qualify"),
76
+ searchable: z.boolean().describe("true if search_assets queries this source"),
77
+ licensePage: z.string(),
78
+ notes: z.string(),
79
+ verified: z.object({ date: z.string().describe("YYYY-MM-DD"), evidence: z.string().describe("Text or field that was checked") }),
80
+ }))
81
+ .describe("Verified CC0 sources"),
82
+ notCc0: z.array(nameReason).describe("Popular 'free' sites that are NOT CC0"),
83
+ pendingVerification: z.array(nameReason).describe("Candidates whose license could not be verified yet"),
84
+ };
85
+ const result = (value) => ({
86
+ structuredContent: value,
87
+ content: [{ type: "text", text: JSON.stringify(value, null, 2) }],
88
+ });
9
89
  const fail = (message) => ({ content: [{ type: "text", text: message }], isError: true });
10
90
  export function createServer(fetchImpl = defaultFetch) {
11
- const server = new McpServer({ name: "cc0-library", version: "0.1.0" });
91
+ const server = new McpServer({ name: "cc0-library", version: "0.2.0" });
12
92
  server.registerTool("search_assets", {
13
- title: "Search CC0 assets",
14
- description: "Search CC0-only images, audio, video, HDRIs, textures, 3D models and museum artworks. Every result was checked as " +
15
- "CC0 1.0 (public domain dedication) and carries licenseEvidence. Sources: Openverse, Wikimedia Commons and " +
16
- "Internet Archive (image, audio, video), Poly Haven and ambientCG (hdri, texture, model), Sketchfab (model), " +
17
- "Cleveland Museum of Art and The Met (artwork). " +
18
- "licenseEvidence.declaredBy says who declared CC0: 'library' or 'institution' (the rights holder) or " +
19
- "'uploader' (a site user; not reviewed, can be wrong). Tell people to check uploader-declared items. " +
20
- "Include each result's servedBy credit when showing results to people.",
93
+ title: "Search CC0 assets across 17 sources",
94
+ description: "Find CC0 1.0 (public-domain dedication) images, audio, video, HDRIs, textures, 3D models and museum artworks by keyword, " +
95
+ "returning only items whose CC0 status was checked. " +
96
+ "Use it first to discover candidates; then call get_asset for download files and a fresh license re-check. " +
97
+ "Use list_sources instead to answer which sites are CC0. Do not use it for CC BY, CC BY-SA or other 'free' licenses: they are filtered out. " +
98
+ "Behavior: read-only, no API key, live HTTPS calls to each source (usually 2-10 s). A failing source is listed in `errors` while the others still return. " +
99
+ "Results from uploader-driven sites (Openverse, Commons, Internet Archive, Sketchfab, WordPress Photo Directory, iNaturalist, PhyloPic, Zenodo, BlenderKit, GitHub, Hugging Face) carry licenseEvidence.declaredBy='uploader': " +
100
+ "tell the user to confirm the uploader owns the work. Show each item's servedBy credit with the results.",
21
101
  inputSchema: {
22
- query: z.string().min(1).max(200).describe("Search words, e.g. 'rainy street' or 'brick wall'"),
23
- kind: z.enum([...ASSET_KINDS, "any"]).default("any").describe("Asset type to search"),
24
- limit: z.number().int().min(1).max(20).default(10).describe("Max results (1-20)"),
25
- page: z.number().int().min(1).max(12).default(1).describe("Result page, starting at 1"),
102
+ query: z.string().min(1).max(200).describe("Keywords in any language, matched against titles and tags, e.g. 'rainy street' or 'brick wall'"),
103
+ kind: z.enum([...ASSET_KINDS, "any"]).default("any").describe(KIND_HELP),
104
+ limit: z
105
+ .number()
106
+ .int()
107
+ .min(1)
108
+ .max(20)
109
+ .default(10)
110
+ .describe("Maximum results to return, 1-20. With kind 'any' the sources are interleaved, so each contributes a few"),
111
+ page: z
112
+ .number()
113
+ .int()
114
+ .min(1)
115
+ .max(12)
116
+ .default(1)
117
+ .describe("1-based page; each source paginates independently. Request page 2+ only if `totals` shows more matches"),
26
118
  },
27
- annotations: { readOnlyHint: true, openWorldHint: true },
28
- }, async ({ query, kind, limit, page }) => json(await search(fetchImpl, query, kind, limit, page)));
119
+ outputSchema: searchOutput,
120
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
121
+ }, async ({ query, kind, limit, page }) => result(await search(fetchImpl, query, kind, limit, page)));
29
122
  server.registerTool("get_asset", {
30
- title: "Get CC0 asset details",
31
- description: "Get details and download URLs for one asset id returned by search_assets " +
32
- "(formats: 'openverse:image:<uuid>', 'openverse:audio:<uuid>', 'polyhaven:<slug>', " +
33
- "'ambientcg:<assetId>', 'cleveland:<number>', 'met:<number>', 'commons:<pageid>', 'archive:<identifier>', " +
34
- "'sketchfab:<uid>'). Sketchfab returns the model page only: its downloads need the user's own login. " +
35
- "Re-checks the CC0 status at the source before returning.",
36
- inputSchema: { id: z.string().min(1).max(120).describe("Asset id from search_assets") },
37
- annotations: { readOnlyHint: true, openWorldHint: true },
123
+ title: "Get one CC0 asset with download files",
124
+ description: "Fetch one asset's details and download files by an id from search_assets, re-checking at the source that it is still CC0. " +
125
+ "Use it after search_assets when the user wants to download or inspect an item; it cannot search, so call search_assets first if you have no id. " +
126
+ "Returns an error (do not retry the same id) when the id is malformed, the item was removed, or the source no longer reports CC0. " +
127
+ "Behavior: read-only, no API key, one or two live HTTPS calls. Poly Haven lists up to 60 resolution/format variants; " +
128
+ "ambientCG returns zip packs; Sketchfab returns only the model page because its downloads need the user's own login.",
129
+ inputSchema: {
130
+ id: z
131
+ .string()
132
+ .min(1)
133
+ .max(120)
134
+ .describe("Asset id exactly as returned by search_assets: openverse:image:<uuid>, openverse:audio:<uuid>, polyhaven:<slug>, " +
135
+ "ambientcg:<assetId>, cleveland:<number>, met:<number>, commons:<pageid>, archive:<identifier>, sketchfab:<uid>, wpphotos:<number>, " +
136
+ "inaturalist:<number>, gbif:<number>, phylopic:<uuid>, iconify:<set>:<icon>, zenodo:<number>, github:<owner>/<repo>, " +
137
+ "huggingface:<owner>/<dataset> or blenderkit:<uuid>"),
138
+ },
139
+ outputSchema: getOutput,
140
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
38
141
  }, async ({ id }) => {
39
142
  const asset = await getAsset(fetchImpl, id);
40
143
  if (!asset)
41
144
  return fail(`No CC0 asset found for id "${id}". The id may be malformed, removed upstream, or no longer CC0.`);
42
145
  const truncated = asset.files.length > MAX_FILES_IN_REPLY;
43
- return json({
146
+ return result({
44
147
  ...asset,
45
148
  files: asset.files.slice(0, MAX_FILES_IN_REPLY),
46
149
  ...(truncated && { filesNote: `${asset.files.length - MAX_FILES_IN_REPLY} more files omitted; see landingUrl.` }),
47
150
  });
48
151
  });
49
152
  server.registerTool("list_sources", {
50
- title: "List curated CC0 sources",
51
- description: "List the curated catalog of CC0 asset sources, with license evidence and the date each was verified. " +
52
- "Also lists popular 'free' sources that are NOT CC0 and why, and candidates still pending verification.",
153
+ title: "List verified CC0 source sites",
154
+ description: "List the curated catalog of CC0 asset sites, each with its license page, scope and dated evidence, " +
155
+ "plus popular 'free' sites that are NOT CC0 (e.g. Unsplash, Pixabay) and candidates still pending verification. " +
156
+ "Use it to answer 'is site X CC0?' or to suggest sites to browse by hand; use search_assets instead to find actual assets. " +
157
+ "Behavior: reads a bundled JSON file, so no network access, instant and deterministic.",
53
158
  inputSchema: {
54
- kind: z.enum([...ASSET_KINDS, "any"]).default("any").describe("Only sources offering this asset type"),
159
+ kind: z
160
+ .enum([...CATALOG_KINDS, "any"])
161
+ .default("any")
162
+ .describe("Keep only sources offering this asset type ('font' is catalog-only); 'any' (default) returns all. Does not filter the notCc0 and pending lists"),
55
163
  },
56
- annotations: { readOnlyHint: true, openWorldHint: false },
164
+ outputSchema: listOutput,
165
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
57
166
  }, async ({ kind }) => {
58
167
  const catalog = loadCatalog();
59
168
  const sources = kind === "any" ? catalog.sources : catalog.sources.filter((s) => s.kinds.includes(kind));
60
- return json({ sources, notCc0: catalog.excluded, pendingVerification: catalog.pending });
169
+ return result({ sources, notCc0: catalog.excluded, pendingVerification: catalog.pending });
61
170
  });
62
171
  return server;
63
172
  }
package/dist/types.js CHANGED
@@ -5,7 +5,14 @@
5
5
  * status of that specific item. `licenseEvidence` records how that was
6
6
  * confirmed, so a caller can re-check it instead of trusting this library.
7
7
  */
8
- /** `artwork` = photos of public-domain museum works (Cleveland Museum of Art, The Met). */
9
- export const ASSET_KINDS = ["image", "audio", "video", "hdri", "texture", "model", "artwork"];
10
- export const PROVIDER_IDS = ["openverse", "polyhaven", "ambientcg", "cleveland", "met", "commons", "archive", "sketchfab"];
8
+ /**
9
+ * `artwork` = photos of public-domain museum works (Cleveland Museum of Art, The Met).
10
+ * `collection` = a pack of many assets in one place (a CC0 GitHub repository or Hugging Face dataset).
11
+ */
12
+ export const ASSET_KINDS = ["image", "audio", "video", "hdri", "texture", "model", "artwork", "collection"];
13
+ /** Kinds a catalog source may list. `font` is catalog-only: no search provider serves fonts. */
14
+ export const CATALOG_KINDS = [...ASSET_KINDS, "font"];
15
+ export const PROVIDER_IDS = ["openverse", "polyhaven", "ambientcg", "cleveland", "met", "commons", "archive", "sketchfab", "wpphotos",
16
+ "inaturalist", "gbif", "phylopic", "iconify", "zenodo", "huggingface", "github", "blenderkit",
17
+ ];
11
18
  export const CC0_LICENSE_URL = "https://creativecommons.org/publicdomain/zero/1.0/";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc0-library-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "mcpName": "io.github.sanghyoLe/cc0-library",
5
5
  "description": "MCP server and web gallery for CC0-only assets (images, audio, video, HDRIs, textures, 3D models, museum art) from 8 sources, with license evidence per result.",
6
6
  "license": "MIT",