cc0-library-mcp 0.1.0 → 0.1.2

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/http.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Poly Haven's API terms require a User-Agent that names the calling app.
3
3
  * Openverse also asks clients to identify themselves.
4
4
  */
5
- export const USER_AGENT = "cc0-library-mcp/0.1.0 (+https://github.com/sanghyoLe/cc0-library)";
5
+ export const USER_AGENT = "cc0-library-mcp/0.1.2 (+https://github.com/sanghyoLe/cc0-library)";
6
6
  const TIMEOUT_MS = 15_000;
7
7
  export class UpstreamError extends Error {
8
8
  provider;
@@ -0,0 +1,70 @@
1
+ import { getJson } from "../http.js";
2
+ import { CC0_LICENSE_URL } from "../types.js";
3
+ /**
4
+ * WordPress Photo Directory (https://wordpress.org/photos/), WP REST API, no key.
5
+ * Every photo is CC0 ("All photos are CC0 licensed" on the directory page), so
6
+ * CC0 is confirmed at library level. Contributors upload their own photos and
7
+ * the directory moderates submissions; the CC0 claim is still the uploader's,
8
+ * so declaredBy is "uploader".
9
+ */
10
+ const BASE = "https://wordpress.org/photos/wp-json/wp/v2/photos";
11
+ const SERVED_BY = "Via WordPress Photo Directory (https://wordpress.org/photos/)";
12
+ /** Photo posts have a generic title ("Photo detail"); the alt text in `content` describes the photo. */
13
+ const TITLE_MAX = 90;
14
+ const text = (html) => (html ?? "").replace(/<[^>]*>/g, " ").replace(/&#8217;/g, "'").replace(/&amp;/g, "&").replace(/&#\d+;/g, " ").replace(/\s+/g, " ").trim();
15
+ export function titleOf(p) {
16
+ const alt = text(p.content?.rendered);
17
+ if (alt)
18
+ return alt.length > TITLE_MAX ? `${alt.slice(0, TITLE_MAX - 1).trimEnd()}…` : alt;
19
+ return text(p.title?.rendered) || `Photo ${p.id}`;
20
+ }
21
+ export function toAsset(p) {
22
+ const media = p._embedded?.["wp:featuredmedia"]?.[0];
23
+ return {
24
+ id: `wpphotos:${p.id}`,
25
+ kind: "image",
26
+ title: titleOf(p),
27
+ creator: p._embedded?.author?.[0]?.name ?? null,
28
+ landingUrl: p.link,
29
+ fileUrl: media?.source_url ?? null,
30
+ thumbnailUrl: p["photo-thumbnail-url"] ?? null,
31
+ tags: [],
32
+ provider: "wpphotos",
33
+ origin: "wordpress.org/photos",
34
+ licenseEvidence: {
35
+ license: "CC0-1.0",
36
+ licenseUrl: CC0_LICENSE_URL,
37
+ method: "whole-library-cc0",
38
+ source: "https://wordpress.org/photos/ ('All photos are CC0 licensed')",
39
+ declaredBy: "uploader",
40
+ },
41
+ servedBy: SERVED_BY,
42
+ };
43
+ }
44
+ export async function searchWpPhotos(fetchImpl, params) {
45
+ const qs = new URLSearchParams({
46
+ search: params.query,
47
+ per_page: String(params.limit),
48
+ page: String(params.page),
49
+ _embed: "author,wp:featuredmedia",
50
+ });
51
+ const photos = await getJson(fetchImpl, "WordPress Photo Directory", `${BASE}?${qs}`);
52
+ // The response total lives in a header the shared fetch helper does not expose; report this page's size.
53
+ return { total: photos.length, assets: photos.map(toAsset) };
54
+ }
55
+ export async function getWpPhoto(fetchImpl, id) {
56
+ if (!/^\d+$/.test(id))
57
+ return null;
58
+ const p = await getJson(fetchImpl, "WordPress Photo Directory", `${BASE}/${id}?_embed=author,wp:featuredmedia`);
59
+ const media = p._embedded?.["wp:featuredmedia"]?.[0];
60
+ const files = [];
61
+ if (media?.source_url) {
62
+ const d = media.media_details;
63
+ files.push({ label: `original${d?.width ? ` (${d.width}×${d.height})` : ""}`, url: media.source_url, sizeBytes: d?.filesize ?? null });
64
+ for (const [name, size] of Object.entries(d?.sizes ?? {})) {
65
+ if (name !== "full")
66
+ files.push({ label: `${name} (${size.width}×${size.height})`, url: size.source_url, sizeBytes: null });
67
+ }
68
+ }
69
+ return { ...toAsset(p), description: text(p.content?.rendered) || null, files };
70
+ }
package/dist/search.js CHANGED
@@ -10,6 +10,7 @@ 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";
13
14
  /**
14
15
  * Runs one search across the providers that serve `kind`. With kind "any",
15
16
  * results from each provider are interleaved so one provider cannot crowd
@@ -39,6 +40,8 @@ export async function search(fetchImpl, query, kind, limit, page, options = {})
39
40
  }
40
41
  if (kind === "model" || kind === "any")
41
42
  all.push({ name: "sketchfab", run: () => searchSketchfab(fetchImpl, params) });
43
+ if (kind === "image" || kind === "any")
44
+ all.push({ name: "wpphotos", run: () => searchWpPhotos(fetchImpl, params) });
42
45
  const skip = new Set(options.skip ?? []);
43
46
  const run = all.filter((j) => !skip.has(j.name.split(":")[0]));
44
47
  const settled = await Promise.allSettled(run.map((j) => j.run()));
@@ -68,7 +71,7 @@ export function interleave(lists) {
68
71
  /**
69
72
  * Resolves ids produced by `search`: `openverse:image:<uuid>`, `openverse:audio:<uuid>`,
70
73
  * `polyhaven:<slug>`, `ambientcg:<assetId>`, `cleveland:<number>`, `met:<number>`,
71
- * `commons:<pageid>`, `archive:<identifier>`, `sketchfab:<uid>`.
74
+ * `commons:<pageid>`, `archive:<identifier>`, `sketchfab:<uid>`, `wpphotos:<number>`.
72
75
  */
73
76
  export async function getAsset(fetchImpl, id) {
74
77
  const parts = id.split(":");
@@ -91,5 +94,7 @@ export async function getAsset(fetchImpl, id) {
91
94
  return getArchive(fetchImpl, a);
92
95
  if (provider === "sketchfab")
93
96
  return getSketchfab(fetchImpl, a);
97
+ if (provider === "wpphotos")
98
+ return getWpPhoto(fetchImpl, a);
94
99
  return null;
95
100
  }
package/dist/server.js CHANGED
@@ -2,62 +2,166 @@ 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, audio, video: Openverse, Wikimedia Commons, Internet Archive (image also: WordPress Photo Directory). " +
9
+ "hdri, texture: Poly Haven, ambientCG. model: Poly Haven, ambientCG, Sketchfab. " +
10
+ "artwork: photos of public-domain works from the Cleveland Museum of Art and The Met. " +
11
+ "any (default): all of the above, interleaved.";
12
+ // ---------- output schemas: every returned field is documented here ----------
13
+ const licenseEvidenceSchema = z
14
+ .object({
15
+ license: z.literal("CC0-1.0").describe("Always CC0-1.0; non-CC0 items are never returned"),
16
+ licenseUrl: z.string().describe("CC0 1.0 deed URL"),
17
+ method: z
18
+ .enum(["per-item-license-field", "whole-library-cc0"])
19
+ .describe("per-item-license-field: the item's own record says CC0; whole-library-cc0: the site publishes everything as CC0"),
20
+ source: z.string().describe("The exact field or policy page the check used, with its URL"),
21
+ declaredBy: z
22
+ .enum(["library", "institution", "uploader"])
23
+ .describe("Who declared CC0. library = the studio that made it; institution = the museum holding the work; " +
24
+ "uploader = a site user, unreviewed and sometimes wrong (warn the user to verify ownership)"),
25
+ })
26
+ .describe("How CC0 status was verified for this item");
27
+ const assetShape = {
28
+ id: z.string().describe("Stable id to pass to get_asset, e.g. 'polyhaven:brown_planks_03' or 'met:436535'"),
29
+ kind: z.enum(ASSET_KINDS).describe("Asset type"),
30
+ title: z.string().describe("Title at the source"),
31
+ creator: z.string().nullable().describe("Creator or uploader name, null if the source gives none"),
32
+ landingUrl: z.string().describe("Human-facing page at the source; link this when showing the item"),
33
+ fileUrl: z.string().nullable().describe("Direct file or preview URL when the search response includes one; use get_asset for all files"),
34
+ thumbnailUrl: z.string().nullable().describe("Small preview image URL, null for audio and some items"),
35
+ tags: z.array(z.string()).describe("Up to 20 source tags or categories"),
36
+ provider: z.enum(PROVIDER_IDS).describe("API that served the item"),
37
+ origin: z.string().describe("Site the item originally came from (e.g. flickr, freesound, metmuseum.org)"),
38
+ licenseEvidence: licenseEvidenceSchema,
39
+ servedBy: z.string().describe("Credit line required by the serving API's terms; show it next to results"),
40
+ };
41
+ const fileSchema = z.object({
42
+ label: z.string().describe("Variant, e.g. '2K-JPG (zip)', 'hdri / 4k / exr', 'primary'"),
43
+ url: z.string().describe("Direct download URL (Sketchfab: model page, login required)"),
44
+ sizeBytes: z.number().nullable().describe("File size in bytes when the source reports it"),
45
+ });
46
+ const nameReason = z.object({
47
+ name: z.string(),
48
+ url: z.string().describe("Site URL"),
49
+ reason: z.string().describe("Why it is listed here"),
50
+ });
51
+ const searchOutput = {
52
+ query: z.string().describe("Query as received"),
53
+ kind: z.enum([...ASSET_KINDS, "any"]).describe("Kind as received"),
54
+ page: z.number().describe("Page as received"),
55
+ assets: z.array(z.object(assetShape)).describe("CC0 results, at most `limit`; may be fewer when sources drop non-CC0 items"),
56
+ totals: z.record(z.string(), z.number()).describe("Upstream match count per source job (before CC0 re-checks); useful to decide whether to page"),
57
+ errors: z.array(z.string()).describe("Sources that failed this time, e.g. 'met: The Met returned HTTP 503'; other sources still returned results"),
58
+ };
59
+ const getOutput = {
60
+ ...assetShape,
61
+ description: z.string().nullable().describe("Source description or credit line, if any"),
62
+ files: z.array(fileSchema).describe(`Downloadable files, at most ${MAX_FILES_IN_REPLY}; empty when the source offers none`),
63
+ filesNote: z.string().optional().describe("Present when files were truncated"),
64
+ };
65
+ const listOutput = {
66
+ sources: z
67
+ .array(z.object({
68
+ id: z.string(),
69
+ name: z.string(),
70
+ url: z.string().describe("Where to browse the source"),
71
+ kinds: z.array(z.enum(CATALOG_KINDS)),
72
+ scope: z.enum(["whole-library", "filter-only"]).describe("whole-library: everything is CC0; filter-only: only CC0-labeled items qualify"),
73
+ searchable: z.boolean().describe("true if search_assets queries this source"),
74
+ licensePage: z.string(),
75
+ notes: z.string(),
76
+ verified: z.object({ date: z.string().describe("YYYY-MM-DD"), evidence: z.string().describe("Text or field that was checked") }),
77
+ }))
78
+ .describe("Verified CC0 sources"),
79
+ notCc0: z.array(nameReason).describe("Popular 'free' sites that are NOT CC0"),
80
+ pendingVerification: z.array(nameReason).describe("Candidates whose license could not be verified yet"),
81
+ };
82
+ const result = (value) => ({
83
+ structuredContent: value,
84
+ content: [{ type: "text", text: JSON.stringify(value, null, 2) }],
85
+ });
9
86
  const fail = (message) => ({ content: [{ type: "text", text: message }], isError: true });
10
87
  export function createServer(fetchImpl = defaultFetch) {
11
- const server = new McpServer({ name: "cc0-library", version: "0.1.0" });
88
+ const server = new McpServer({ name: "cc0-library", version: "0.1.2" });
12
89
  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.",
90
+ title: "Search CC0 assets across 9 sources",
91
+ description: "Find CC0 1.0 (public-domain dedication) images, audio, video, HDRIs, textures, 3D models and museum artworks by keyword, " +
92
+ "returning only items whose CC0 status was checked. " +
93
+ "Use it first to discover candidates; then call get_asset for download files and a fresh license re-check. " +
94
+ "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. " +
95
+ "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. " +
96
+ "Results from uploader-driven sites (Openverse, Commons, Internet Archive, Sketchfab, WordPress Photo Directory) carry licenseEvidence.declaredBy='uploader': " +
97
+ "tell the user to confirm the uploader owns the work. Show each item's servedBy credit with the results.",
21
98
  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"),
99
+ query: z.string().min(1).max(200).describe("Keywords in any language, matched against titles and tags, e.g. 'rainy street' or 'brick wall'"),
100
+ kind: z.enum([...ASSET_KINDS, "any"]).default("any").describe(KIND_HELP),
101
+ limit: z
102
+ .number()
103
+ .int()
104
+ .min(1)
105
+ .max(20)
106
+ .default(10)
107
+ .describe("Maximum results to return, 1-20. With kind 'any' the sources are interleaved, so each contributes a few"),
108
+ page: z
109
+ .number()
110
+ .int()
111
+ .min(1)
112
+ .max(12)
113
+ .default(1)
114
+ .describe("1-based page; each source paginates independently. Request page 2+ only if `totals` shows more matches"),
26
115
  },
27
- annotations: { readOnlyHint: true, openWorldHint: true },
28
- }, async ({ query, kind, limit, page }) => json(await search(fetchImpl, query, kind, limit, page)));
116
+ outputSchema: searchOutput,
117
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
118
+ }, async ({ query, kind, limit, page }) => result(await search(fetchImpl, query, kind, limit, page)));
29
119
  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 },
120
+ title: "Get one CC0 asset with download files",
121
+ 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. " +
122
+ "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. " +
123
+ "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. " +
124
+ "Behavior: read-only, no API key, one or two live HTTPS calls. Poly Haven lists up to 60 resolution/format variants; " +
125
+ "ambientCG returns zip packs; Sketchfab returns only the model page because its downloads need the user's own login.",
126
+ inputSchema: {
127
+ id: z
128
+ .string()
129
+ .min(1)
130
+ .max(120)
131
+ .describe("Asset id exactly as returned by search_assets: openverse:image:<uuid>, openverse:audio:<uuid>, polyhaven:<slug>, " +
132
+ "ambientcg:<assetId>, cleveland:<number>, met:<number>, commons:<pageid>, archive:<identifier>, sketchfab:<uid> or wpphotos:<number>"),
133
+ },
134
+ outputSchema: getOutput,
135
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
38
136
  }, async ({ id }) => {
39
137
  const asset = await getAsset(fetchImpl, id);
40
138
  if (!asset)
41
139
  return fail(`No CC0 asset found for id "${id}". The id may be malformed, removed upstream, or no longer CC0.`);
42
140
  const truncated = asset.files.length > MAX_FILES_IN_REPLY;
43
- return json({
141
+ return result({
44
142
  ...asset,
45
143
  files: asset.files.slice(0, MAX_FILES_IN_REPLY),
46
144
  ...(truncated && { filesNote: `${asset.files.length - MAX_FILES_IN_REPLY} more files omitted; see landingUrl.` }),
47
145
  });
48
146
  });
49
147
  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.",
148
+ title: "List verified CC0 source sites",
149
+ description: "List the curated catalog of CC0 asset sites, each with its license page, scope and dated evidence, " +
150
+ "plus popular 'free' sites that are NOT CC0 (e.g. Unsplash, Pixabay) and candidates still pending verification. " +
151
+ "Use it to answer 'is site X CC0?' or to suggest sites to browse by hand; use search_assets instead to find actual assets. " +
152
+ "Behavior: reads a bundled JSON file, so no network access, instant and deterministic.",
53
153
  inputSchema: {
54
- kind: z.enum([...ASSET_KINDS, "any"]).default("any").describe("Only sources offering this asset type"),
154
+ kind: z
155
+ .enum([...CATALOG_KINDS, "any"])
156
+ .default("any")
157
+ .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
158
  },
56
- annotations: { readOnlyHint: true, openWorldHint: false },
159
+ outputSchema: listOutput,
160
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
57
161
  }, async ({ kind }) => {
58
162
  const catalog = loadCatalog();
59
163
  const sources = kind === "any" ? catalog.sources : catalog.sources.filter((s) => s.kinds.includes(kind));
60
- return json({ sources, notCc0: catalog.excluded, pendingVerification: catalog.pending });
164
+ return result({ sources, notCc0: catalog.excluded, pendingVerification: catalog.pending });
61
165
  });
62
166
  return server;
63
167
  }
package/dist/types.js CHANGED
@@ -7,5 +7,7 @@
7
7
  */
8
8
  /** `artwork` = photos of public-domain museum works (Cleveland Museum of Art, The Met). */
9
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"];
10
+ /** Kinds a catalog source may list. `font` is catalog-only: no search provider serves fonts. */
11
+ export const CATALOG_KINDS = [...ASSET_KINDS, "font"];
12
+ export const PROVIDER_IDS = ["openverse", "polyhaven", "ambientcg", "cleveland", "met", "commons", "archive", "sketchfab", "wpphotos"];
11
13
  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.1.2",
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",