@rahmandayub/pexels-mcp 0.0.0-stage → 0.2.1

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.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +192 -2
  3. package/dist/cache.js +77 -0
  4. package/dist/cache.js.map +1 -0
  5. package/dist/config.js +127 -0
  6. package/dist/config.js.map +1 -0
  7. package/dist/errors.js +57 -0
  8. package/dist/errors.js.map +1 -0
  9. package/dist/index.js +77 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/log.js +54 -0
  12. package/dist/log.js.map +1 -0
  13. package/dist/pexels/client.js +193 -0
  14. package/dist/pexels/client.js.map +1 -0
  15. package/dist/pexels/quirks.js +283 -0
  16. package/dist/pexels/quirks.js.map +1 -0
  17. package/dist/pexels/schemas.js +134 -0
  18. package/dist/pexels/schemas.js.map +1 -0
  19. package/dist/present/collection.js +23 -0
  20. package/dist/present/collection.js.map +1 -0
  21. package/dist/present/envelope.js +20 -0
  22. package/dist/present/envelope.js.map +1 -0
  23. package/dist/present/photo.js +86 -0
  24. package/dist/present/photo.js.map +1 -0
  25. package/dist/present/util.js +24 -0
  26. package/dist/present/util.js.map +1 -0
  27. package/dist/present/video.js +117 -0
  28. package/dist/present/video.js.map +1 -0
  29. package/dist/tools/collection-media.js +54 -0
  30. package/dist/tools/collection-media.js.map +1 -0
  31. package/dist/tools/curated-photos.js +42 -0
  32. package/dist/tools/curated-photos.js.map +1 -0
  33. package/dist/tools/featured-collections.js +42 -0
  34. package/dist/tools/featured-collections.js.map +1 -0
  35. package/dist/tools/get-photo.js +46 -0
  36. package/dist/tools/get-photo.js.map +1 -0
  37. package/dist/tools/get-video.js +46 -0
  38. package/dist/tools/get-video.js.map +1 -0
  39. package/dist/tools/helpers.js +38 -0
  40. package/dist/tools/helpers.js.map +1 -0
  41. package/dist/tools/index.js +21 -0
  42. package/dist/tools/index.js.map +1 -0
  43. package/dist/tools/photo-url.js +84 -0
  44. package/dist/tools/photo-url.js.map +1 -0
  45. package/dist/tools/popular-videos.js +62 -0
  46. package/dist/tools/popular-videos.js.map +1 -0
  47. package/dist/tools/preview.js +21 -0
  48. package/dist/tools/preview.js.map +1 -0
  49. package/dist/tools/search-photos.js +67 -0
  50. package/dist/tools/search-photos.js.map +1 -0
  51. package/dist/tools/search-videos.js +60 -0
  52. package/dist/tools/search-videos.js.map +1 -0
  53. package/dist/types.js +118 -0
  54. package/dist/types.js.map +1 -0
  55. package/dist/version.js +6 -0
  56. package/dist/version.js.map +1 -0
  57. package/package.json +52 -4
@@ -0,0 +1,23 @@
1
+ import { truncate } from './util.js';
2
+ export function presentCollection(raw) {
3
+ return {
4
+ type: 'collection',
5
+ id: String(raw.id),
6
+ title: raw.title?.trim() || '(untitled collection)',
7
+ description: raw.description ?? null,
8
+ private: raw.private,
9
+ media_count: raw.media_count,
10
+ photos_count: raw.photos_count,
11
+ videos_count: raw.videos_count,
12
+ };
13
+ }
14
+ export function collectionBlock(collection) {
15
+ const counts = `${collection.media_count} media (${collection.photos_count} photos, ${collection.videos_count} videos)`;
16
+ const visibility = collection.private ? ', private' : '';
17
+ const lines = [`- [${collection.id}] "${collection.title}" — ${counts}${visibility}`];
18
+ if (collection.description) {
19
+ lines.push(` ${truncate(collection.description, 140)}`);
20
+ }
21
+ return lines.join('\n');
22
+ }
23
+ //# sourceMappingURL=collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/present/collection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,UAAU,iBAAiB,CAAC,GAAkB;IAClD,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAClB,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,uBAAuB;QACnD,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,IAAI;QACpC,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,YAAY,EAAE,GAAG,CAAC,YAAY;QAC9B,YAAY,EAAE,GAAG,CAAC,YAAY;KAC/B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,UAAyB;IACvD,MAAM,MAAM,GAAG,GAAG,UAAU,CAAC,WAAW,WAAW,UAAU,CAAC,YAAY,YAAY,UAAU,CAAC,YAAY,UAAU,CAAC;IACxH,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IACzD,MAAM,KAAK,GAAG,CAAC,MAAM,UAAU,CAAC,EAAE,MAAM,UAAU,CAAC,KAAK,OAAO,MAAM,GAAG,UAAU,EAAE,CAAC,CAAC;IACtF,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,QAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,20 @@
1
+ export function listHeader(label, pagination, count) {
2
+ const total = pagination.total_results ?? count;
3
+ return `${total} ${label} — page ${pagination.page} (per_page ${pagination.per_page})`;
4
+ }
5
+ export function listFooter(pagination) {
6
+ const parts = [];
7
+ if (pagination.next_page !== undefined)
8
+ parts.push(`next: page=${pagination.next_page}`);
9
+ if (pagination.prev_page !== undefined)
10
+ parts.push(`prev: page=${pagination.prev_page}`);
11
+ return parts.length > 0 ? parts.join(' ') : 'no further pages';
12
+ }
13
+ /** Empty results are not an error: say so, and suggest what to relax. */
14
+ export function emptyNote(subject, hints) {
15
+ const lines = [`No ${subject}.`];
16
+ for (const hint of hints)
17
+ lines.push(`- ${hint}`);
18
+ return lines.join('\n');
19
+ }
20
+ //# sourceMappingURL=envelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../src/present/envelope.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,UAAU,CAAC,KAAa,EAAE,UAAsB,EAAE,KAAa;IAC7E,MAAM,KAAK,GAAG,UAAU,CAAC,aAAa,IAAI,KAAK,CAAC;IAChD,OAAO,GAAG,KAAK,IAAI,KAAK,WAAW,UAAU,CAAC,IAAI,cAAc,UAAU,CAAC,QAAQ,GAAG,CAAC;AACzF,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,UAAsB;IAC/C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,UAAU,CAAC,SAAS,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,cAAc,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;IACzF,IAAI,UAAU,CAAC,SAAS,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,cAAc,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;IACzF,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC;AAClE,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,KAAwB;IACjE,MAAM,KAAK,GAAG,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC;IACjC,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAClD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,86 @@
1
+ import { aspectRatio, orientationOf } from '../pexels/quirks.js';
2
+ import { asUrl, photoPageFallback, truncate } from './util.js';
3
+ const RENDITION_KEYS = [
4
+ 'original',
5
+ 'large2x',
6
+ 'large',
7
+ 'medium',
8
+ 'small',
9
+ 'portrait',
10
+ 'landscape',
11
+ 'tiny',
12
+ ];
13
+ function pickSrc(src, ...keys) {
14
+ for (const key of keys) {
15
+ const value = src[key];
16
+ if (typeof value === 'string' && value.trim() !== '')
17
+ return value;
18
+ }
19
+ return undefined;
20
+ }
21
+ function renditions(src) {
22
+ const out = {};
23
+ for (const key of RENDITION_KEYS) {
24
+ const value = src[key];
25
+ if (typeof value === 'string' && /^https?:\/\//i.test(value))
26
+ out[key] = value;
27
+ }
28
+ return Object.keys(out).length > 0 ? out : undefined;
29
+ }
30
+ export function presentPhoto(raw, detail) {
31
+ const page = asUrl(raw.url, photoPageFallback(raw.id));
32
+ const preview = asUrl(pickSrc(raw.src, 'medium', 'large', 'small', 'original'), page);
33
+ const download = asUrl(pickSrc(raw.src, 'large2x', 'large', 'original'), page);
34
+ const out = {
35
+ type: 'photo',
36
+ id: raw.id,
37
+ width: raw.width,
38
+ height: raw.height,
39
+ aspect_ratio: aspectRatio(raw.width, raw.height),
40
+ orientation: orientationOf(raw.width, raw.height),
41
+ alt: raw.alt ?? null,
42
+ photographer: {
43
+ name: raw.photographer,
44
+ url: asUrl(raw.photographer_url, page),
45
+ id: raw.photographer_id,
46
+ },
47
+ page_url: page,
48
+ preview_url: preview,
49
+ download_url: download,
50
+ };
51
+ if (detail === 'full') {
52
+ out.avg_color = raw.avg_color ?? null;
53
+ if (raw.liked !== undefined)
54
+ out.liked = raw.liked;
55
+ const all = renditions(raw.src);
56
+ if (all)
57
+ out.renditions = all;
58
+ }
59
+ return out;
60
+ }
61
+ export function photoBlock(photo, detail) {
62
+ const alt = photo.alt ? ` "${truncate(photo.alt, 110)}"` : '';
63
+ const lines = [
64
+ `id=${photo.id} ${photo.width}x${photo.height} (${photo.aspect_ratio})${alt} by ${photo.photographer.name}`,
65
+ ` page: ${photo.page_url}`,
66
+ ` img: ${photo.preview_url}`,
67
+ ` dl: ${photo.download_url}`,
68
+ ];
69
+ if (detail === 'full') {
70
+ const meta = [];
71
+ if (photo.avg_color)
72
+ meta.push(`avg_color: ${photo.avg_color}`);
73
+ if (photo.liked !== undefined)
74
+ meta.push(`liked: ${photo.liked}`);
75
+ if (meta.length > 0)
76
+ lines.push(` ${meta.join(' ')}`);
77
+ if (photo.renditions) {
78
+ lines.push(' renditions:');
79
+ for (const [key, url] of Object.entries(photo.renditions)) {
80
+ lines.push(` ${key}: ${url}`);
81
+ }
82
+ }
83
+ }
84
+ return lines.join('\n');
85
+ }
86
+ //# sourceMappingURL=photo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"photo.js","sourceRoot":"","sources":["../../src/present/photo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGjE,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE/D,MAAM,cAAc,GAAG;IACrB,UAAU;IACV,SAAS;IACT,OAAO;IACP,QAAQ;IACR,OAAO;IACP,UAAU;IACV,WAAW;IACX,MAAM;CACE,CAAC;AAEX,SAAS,OAAO,CAAC,GAA2B,EAAE,GAAG,IAAuB;IACtE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,KAAK,CAAC;IACrE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,UAAU,CAAC,GAA2B;IAC7C,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,eAAe,CAAC,IAAI,CAAC,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AAM,GAAG,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAExD,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAC5B,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC1D,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,KAAK,GAAG,EAAE,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,24 @@
1
+ /** Shared helpers for the pure presentation layer. */
2
+ export function truncate(value, max) {
3
+ const single = value.replace(/\s+/g, ' ').trim();
4
+ return single.length <= max ? single : `${single.slice(0, max - 1)}…`;
5
+ }
6
+ /** Keep only real http(s) URLs so output schema validation can never fail on junk. */
7
+ export function asUrl(value, fallback) {
8
+ const candidate = (value ?? '').trim();
9
+ return /^https?:\/\/\S+$/i.test(candidate) ? candidate : fallback;
10
+ }
11
+ export function photoPageFallback(id) {
12
+ return `https://www.pexels.com/photo/${id}/`;
13
+ }
14
+ export function videoPageFallback(id) {
15
+ return `https://www.pexels.com/video/${id}/`;
16
+ }
17
+ /** Join a header, item blocks, and a footer with exactly one blank line between them. */
18
+ export function joinBlocks(header, blocks, footer) {
19
+ const parts = [header, ...blocks.filter((block) => block.trim() !== '')];
20
+ if (footer.trim() !== '')
21
+ parts.push(footer);
22
+ return parts.join('\n\n');
23
+ }
24
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/present/util.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAEtD,MAAM,UAAU,QAAQ,CAAC,KAAa,EA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 const FULL_PICTURE_COUNT = 3;
4
+ function qualityOf(file) {
5
+ const declared = (file.quality ?? '').trim().toLowerCase();
6
+ if (declared !== '')
7
+ return declared;
8
+ const height = file.height ?? 0;
9
+ if (height >= 2160)
10
+ return 'uhd';
11
+ if (height >= 1080)
12
+ return 'hd';
13
+ return 'sd';
14
+ }
15
+ const BYTES_PER_MB = 1024 * 1024;
16
+ function sizeMb(bytes) {
17
+ return typeof bytes === 'number' && bytes > 0 ? round1(bytes / BYTES_PER_MB) : null;
18
+ }
19
+ function toFileOut(file) {
20
+ const url = asUrl(file.link, '');
21
+ if (url === '')
22
+ return null;
23
+ return {
24
+ quality: qualityOf(file),
25
+ width: file.width ?? null,
26
+ height: file.height ?? null,
27
+ // Quirk #11: float artifacts like 29.969999 become 30.
28
+ fps: typeof file.fps === 'number' ? round1(file.fps) : null,
29
+ size_mb: sizeMb(file.size),
30
+ content_type: file.file_type ?? null,
31
+ url,
32
+ };
33
+ }
34
+ export function presentVideo(raw, detail) {
35
+ const page = asUrl(raw.url, videoPageFallback(raw.id));
36
+ const files = raw.video_files
37
+ .map(toFileOut)
38
+ .filter((file) => file !== null);
39
+ const selected = detail === 'full' ? files : bestOf(files);
40
+ const out = {
41
+ type: 'video',
42
+ id: raw.id,
43
+ width: raw.width,
44
+ height: raw.height,
45
+ aspect_ratio: aspectRatio(raw.width, raw.height),
46
+ orientation: orientationOf(raw.width, raw.height),
47
+ duration_seconds: Math.round(raw.duration ?? 0),
48
+ creator: {
49
+ name: raw.user?.name ?? '',
50
+ url: asUrl(raw.user?.url, page),
51
+ id: raw.user?.id ?? 0,
52
+ },
53
+ page_url: page,
54
+ thumbnail_url: asUrl(raw.image, page),
55
+ files: selected,
56
+ };
57
+ if (detail === 'full') {
58
+ const tags = (raw.tags ?? []).filter((tag) => tag.trim() !== '');
59
+ // Quirk #12: omit the field entirely when there are no tags.
60
+ if (tags.length > 0)
61
+ out.tags = tags;
62
+ const pictures = raw.video_pictures
63
+ .slice()
64
+ .sort((a, b) => (a.nr ?? 0) - (b.nr ?? 0))
65
+ .slice(0, FULL_PICTURE_COUNT)
66
+ .map((picture, index) => ({
67
+ url: asUrl(picture.picture, page),
68
+ index: picture.nr ?? index,
69
+ }));
70
+ if (pictures.length > 0)
71
+ out.pictures = pictures;
72
+ }
73
+ return out;
74
+ }
75
+ function bestOf(files) {
76
+ const best = bestVideoFile(files);
77
+ return best ? [best] : [];
78
+ }
79
+ export function videoBlock(video, detail) {
80
+ const lines = [
81
+ `id=${video.id} ${video.width}x${video.height} (${video.aspect_ratio}) ${video.duration_seconds}s by ${video.creator.name}`,
82
+ ` page: ${video.page_url}`,
83
+ ` thumbnail: ${video.thumbnail_url}`,
84
+ ];
85
+ if (video.files.length === 0) {
86
+ lines.push(' files: none reported by Pexels');
87
+ }
88
+ else if (detail === 'full') {
89
+ lines.push(' files:');
90
+ for (const file of video.files) {
91
+ lines.push(` ${fileLine(file)}`);
92
+ }
93
+ }
94
+ else {
95
+ lines.push(` file: ${fileLine(video.files[0])}`);
96
+ }
97
+ if (detail === 'full') {
98
+ if (video.tags && video.tags.length > 0) {
99
+ lines.push(` tags: ${truncate(video.tags.join(', '), 160)}`);
100
+ }
101
+ if (video.pictures && video.pictures.length > 0) {
102
+ lines.push(' pictures:');
103
+ for (const picture of video.pictures) {
104
+ lines.push(` #${picture.index}: ${picture.url}`);
105
+ }
106
+ }
107
+ }
108
+ return lines.join('\n');
109
+ }
110
+ function fileLine(file) {
111
+ const size = `${file.width ?? '?'}x${file.height ?? '?'}`;
112
+ const fps = file.fps === null ? '' : ` ${file.fps}fps`;
113
+ const mb = file.size_mb === null ? '' : ` ${file.size_mb}MB`;
114
+ const type = file.content_type ? ` ${file.content_type}` : '';
115
+ return `${file.quality} ${size}${fps}${mb}${type}: ${file.url}`;
116
+ }
117
+ //# sourceMappingURL=video.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video.js","sourceRoot":"","sources":["../../src/present/video.ts"],"names":[],"mappings":"AAAA,OA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AAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC1B,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACrC,KAAK,CAAC,IAAI,CAAC,QAAQ,OAAO,CAAC,KAAK,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,QAAQ,CAAC,IAAkB;IAClC,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,KAAK,CAAC;IACvD,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC;IAC7D,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,IAAI,GAAG,GAAG,GAAG,EAAE,GAAG,IAAI,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC;AAClE,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { z } from 'zod';
2
+ import { listFooter, listHeader } from '../present/envelope.js';
3
+ import { presentPhoto, photoBlock } from '../present/photo.js';
4
+ import { joinBlocks } from '../present/util.js';
5
+ import { presentVideo, videoBlock } from '../present/video.js';
6
+ import { collectionMediaPath, derivePagination } from '../pexels/quirks.js';
7
+ import { ApiCollectionMedia } from '../pexels/schemas.js';
8
+ import { Detail, MediaListOut, MediaType, PageInput, PerPageInput } from '../types.js';
9
+ import { READ_ONLY_ANNOTATIONS, runTool } from './helpers.js';
10
+ export const collectionMediaInput = z.object({
11
+ id: z
12
+ .string()
13
+ .transform((value) => value.trim())
14
+ .pipe(z.string().min(1, 'id must not be empty — get one from featured_collections'))
15
+ .describe('Collection id, e.g. "a1er2jh"'),
16
+ media_type: MediaType.optional().describe('photos, videos, or omit for both'),
17
+ page: PageInput,
18
+ per_page: PerPageInput,
19
+ detail: Detail,
20
+ });
21
+ export function registerCollectionMedia(server, ctx) {
22
+ server.registerTool('collection_media', {
23
+ title: 'Collection media',
24
+ description: 'Photos and/or videos inside a Pexels collection. Pexels labels these items with capitalised type tags — pexels-mcp normalises them to "photo"/"video".',
25
+ inputSchema: collectionMediaInput,
26
+ outputSchema: MediaListOut,
27
+ annotations: READ_ONLY_ANNOTATIONS,
28
+ }, async (args) => runTool('collection_media', async () => {
29
+ const { value, cacheHit } = await ctx.client.get(collectionMediaPath(args.id), {
30
+ type: args.media_type,
31
+ page: args.page,
32
+ per_page: args.per_page,
33
+ }, ApiCollectionMedia);
34
+ const pagination = derivePagination({
35
+ page: args.page,
36
+ per_page: args.per_page,
37
+ count: value.media.length,
38
+ total_results: value.total_results,
39
+ hasNextHint: Boolean(value.next_page),
40
+ });
41
+ const results = value.media.map((item) => item.type === 'photo' ? presentPhoto(item, args.detail) : presentVideo(item, args.detail));
42
+ const blocks = results.map((item) => item.type === 'photo' ? photoBlock(item, args.detail) : videoBlock(item, args.detail));
43
+ const text = results.length === 0
44
+ ? `Collection ${args.id} has no ${args.media_type ?? 'media'} on this page.\n- try media_type="photos" or media_type="videos"\n- check the id with featured_collections`
45
+ : joinBlocks(listHeader(args.media_type ?? 'media items', pagination, results.length), blocks, listFooter(pagination));
46
+ return {
47
+ text,
48
+ structured: { count: results.length, pagination, results },
49
+ count: results.length,
50
+ cacheHit,
51
+ };
52
+ }));
53
+ }
54
+ //# sourceMappingURL=collection-media.js.map
@@ -0,0 +1 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I,EAAE,IAAI,CAAC,MAAM,CAAC,CACtF,CAAC;QAEF,MAAM,IAAI,GACR,OAAO,CAAC,MAAM,KAAK,CAAC;YAClB,CAAC,CAAC,cAAc,IAAI,CAAC,EAAE,WAAW,IAAI,CAAC,UAAU,IAAI,OAAO,4GAA4G;YACxK,CAAC,CAAC,UAAU,CACR,UAAU,CAAC,IAAI,CAAC,UAAU,IAAI,aAAa,EAAE,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,EACxE,MAAM,EACN,UAAU,CAAC,UAAU,CAAC,CACvB,CAAC;QAER,OAAO;YACL,IAAI;YACJ,UAAU,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE;YAC1D,KAAK,EAAE,OAAO,CAAC,MAAM;YACrB,QAAQ;SACT,CAAC;IACJ,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { z } from 'zod';
2
+ import { listFooter, listHeader } from '../present/envelope.js';
3
+ import { presentPhoto, photoBlock } from '../present/photo.js';
4
+ import { joinBlocks } from '../present/util.js';
5
+ import { derivePagination } from '../pexels/quirks.js';
6
+ import { ApiPhotoList } from '../pexels/schemas.js';
7
+ import { Detail, PageInput, PerPageInput, PhotoListOut } from '../types.js';
8
+ import { READ_ONLY_ANNOTATIONS, runTool } from './helpers.js';
9
+ export const curatedPhotosInput = z.object({
10
+ page: PageInput,
11
+ per_page: PerPageInput,
12
+ detail: Detail,
13
+ });
14
+ export function registerCuratedPhotos(server, ctx) {
15
+ server.registerTool('curated_photos', {
16
+ title: 'Curated photos',
17
+ description: 'Photos hand-picked by Pexels editors. Use it when the user wants inspiration rather than a specific subject.',
18
+ inputSchema: curatedPhotosInput,
19
+ outputSchema: PhotoListOut,
20
+ annotations: READ_ONLY_ANNOTATIONS,
21
+ }, async (args) => runTool('curated_photos', async () => {
22
+ const { value, cacheHit } = await ctx.client.get('/v1/curated', { page: args.page, per_page: args.per_page }, ApiPhotoList);
23
+ const pagination = derivePagination({
24
+ page: args.page,
25
+ per_page: args.per_page,
26
+ count: value.photos.length,
27
+ total_results: value.total_results,
28
+ hasNextHint: Boolean(value.next_page),
29
+ });
30
+ const results = value.photos.map((photo) => presentPhoto(photo, args.detail));
31
+ const text = results.length === 0
32
+ ? 'No curated photos on this page. Try page=1.'
33
+ : joinBlocks(listHeader('curated photos', pagination, results.length), results.map((photo) => photoBlock(photo, args.detail)), listFooter(pagination));
34
+ return {
35
+ text,
36
+ structured: { count: results.length, pagination, results },
37
+ count: results.length,
38
+ cacheHit,
39
+ };
40
+ }));
41
+ }
42
+ //# sourceMappingURL=curated-photos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"curated-photos.js","sourceRoot":"","sources":["../../src/tools/curated-photos.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAoB,MAAM,cAAc,CAAC;AAEhF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,YAAY;IACtB,MAAM,EAAE,MAAM;CACf,CAAC,CAAC;AAEH,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,GAAgB;IACvE,MAAM,CAAC,YAAY,CACjB,gBAAgB,EA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EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE;YAC1D,KAAK,EAAE,OAAO,CAAC,MAAM;YACrB,QAAQ;SACT,CAAC;IACJ,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { z } from 'zod';
2
+ import { collectionBlock } from '../present/collection.js';
3
+ import { listFooter, listHeader } from '../present/envelope.js';
4
+ import { joinBlocks } from '../present/util.js';
5
+ import { derivePagination } from '../pexels/quirks.js';
6
+ import { ApiCollectionList } from '../pexels/schemas.js';
7
+ import { presentCollection } from '../present/collection.js';
8
+ import { CollectionListOut, PageInput, PerPageInput } from '../types.js';
9
+ import { READ_ONLY_ANNOTATIONS, runTool } from './helpers.js';
10
+ export const featuredCollectionsInput = z.object({
11
+ page: PageInput,
12
+ per_page: PerPageInput,
13
+ });
14
+ export function registerFeaturedCollections(server, ctx) {
15
+ server.registerTool('featured_collections', {
16
+ title: 'Featured collections',
17
+ description: 'Curated Pexels collections with photo/video counts. Take an id from here and pass it to collection_media.',
18
+ inputSchema: featuredCollectionsInput,
19
+ outputSchema: CollectionListOut,
20
+ annotations: READ_ONLY_ANNOTATIONS,
21
+ }, async (args) => runTool('featured_collections', async () => {
22
+ const { value, cacheHit } = await ctx.client.get('/v1/collections/featured', { page: args.page, per_page: args.per_page }, ApiCollectionList);
23
+ const pagination = derivePagination({
24
+ page: args.page,
25
+ per_page: args.per_page,
26
+ count: value.collections.length,
27
+ total_results: value.total_results,
28
+ hasNextHint: Boolean(value.next_page),
29
+ });
30
+ const results = value.collections.map(presentCollection);
31
+ const text = results.length === 0
32
+ ? 'No featured collections on this page. Try page=1.'
33
+ : joinBlocks(listHeader('collections', pagination, results.length), results.map(collectionBlock), listFooter(pagination));
34
+ return {
35
+ text,
36
+ structured: { count: results.length, pagination, results },
37
+ count: results.length,
38
+ cacheHit,
39
+ };
40
+ }));
41
+ }
42
+ //# sourceMappingURL=featured-collections.js.map
@@ -0,0 +1 @@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C5C,iBAAiB,CAClB,CAAC;QAEF,MAAM,UAAU,GAAG,gBAAgB,CAAC;YAClC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM;YAC/B,aAAa,EAAE,KAAK,CAAC,aAAa;YAClC,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC;SACtC,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAEzD,MAAM,IAAI,GACR,OAAO,CAAC,MAAM,KAAK,CAAC;YAClB,CAAC,CAAC,mDAAmD;YACrD,CAAC,CAAC,UAAU,CACR,UAAU,CAAC,aAAa,EAAE,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,EACrD,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAC5B,UAAU,CAAC,UAAU,CAAC,CACvB,CAAC;QAER,OAAO;YACL,IAAI;YACJ,UAAU,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE;YAC1D,KAAK,EAAE,OAAO,CAAC,MAAM;YACrB,QAAQ;SACT,CAAC;IACJ,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod';
2
+ import { presentPhoto, photoBlock } from '../present/photo.js';
3
+ import { photoByIdPath } from '../pexels/quirks.js';
4
+ import { ApiPhoto } from '../pexels/schemas.js';
5
+ import { Detail, PhotoOut } from '../types.js';
6
+ import { READ_ONLY_ANNOTATIONS, runTool } from './helpers.js';
7
+ import { previewImage } from './preview.js';
8
+ export const getPhotoInput = z.object({
9
+ id: z.number().int('id must be a whole number').positive('id must be a positive integer'),
10
+ detail: Detail,
11
+ preview: z
12
+ .boolean()
13
+ .default(false)
14
+ .describe('Also attach a small inline image (~480px) so you can see the photo instead of only its URLs'),
15
+ });
16
+ export function registerGetPhoto(server, ctx) {
17
+ server.registerTool('get_photo', {
18
+ title: 'Get photo by id',
19
+ description: 'Fetch a single photo by its Pexels id. Use detail="full" for every rendition, or preview=true to also see the image inline.',
20
+ inputSchema: getPhotoInput,
21
+ outputSchema: PhotoOut,
22
+ annotations: READ_ONLY_ANNOTATIONS,
23
+ }, async (args) => runTool('get_photo', async () => {
24
+ const { value, cacheHit } = await ctx.client.get(photoByIdPath(args.id), {}, ApiPhoto);
25
+ const photo = presentPhoto(value, args.detail);
26
+ const images = [];
27
+ let note = '';
28
+ if (args.preview) {
29
+ const image = await previewImage(ctx.client, photo.preview_url);
30
+ if (image === null) {
31
+ note = '\n\npreview image unavailable: Pexels returned no CDN URL for this photo';
32
+ }
33
+ else {
34
+ images.push(image);
35
+ }
36
+ }
37
+ return {
38
+ text: photoBlock(photo, args.detail) + note,
39
+ structured: photo,
40
+ count: 1,
41
+ cacheHit,
42
+ images,
43
+ };
44
+ }));
45
+ }
46
+ //# sourceMappingURL=get-photo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-photo.js","sourceRoot":"","sources":["../../src/tools/get-photo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAoB,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,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I;YAC3C,UAAU,EAAE,KAA2C;YACvD,KAAK,EAAE,CAAC;YACR,QAAQ;YACR,MAAM;SACP,CAAC;IACJ,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { z } from 'zod';
2
+ import { presentVideo, videoBlock } from '../present/video.js';
3
+ import { videoByIdPath } from '../pexels/quirks.js';
4
+ import { ApiVideo } from '../pexels/schemas.js';
5
+ import { Detail, VideoOut } from '../types.js';
6
+ import { READ_ONLY_ANNOTATIONS, runTool } from './helpers.js';
7
+ import { previewImage } from './preview.js';
8
+ export const getVideoInput = z.object({
9
+ id: z.number().int('id must be a whole number').positive('id must be a positive integer'),
10
+ detail: Detail,
11
+ preview: z
12
+ .boolean()
13
+ .default(false)
14
+ .describe('Also attach the video thumbnail inline (~480px) so you can see the shot instead of only its URLs'),
15
+ });
16
+ export function registerGetVideo(server, ctx) {
17
+ server.registerTool('get_video', {
18
+ title: 'Get video by id',
19
+ description: 'Fetch a single video by its Pexels id. Use detail="full" to list every quality with fps, or preview=true to see the thumbnail inline.',
20
+ inputSchema: getVideoInput,
21
+ outputSchema: VideoOut,
22
+ annotations: READ_ONLY_ANNOTATIONS,
23
+ }, async (args) => runTool('get_video', async () => {
24
+ const { value, cacheHit } = await ctx.client.get(videoByIdPath(args.id), {}, ApiVideo);
25
+ const video = presentVideo(value, args.detail);
26
+ const images = [];
27
+ let note = '';
28
+ if (args.preview) {
29
+ const image = await previewImage(ctx.client, video.thumbnail_url);
30
+ if (image === null) {
31
+ note = '\n\npreview image unavailable: Pexels returned no CDN URL for this video';
32
+ }
33
+ else {
34
+ images.push(image);
35
+ }
36
+ }
37
+ return {
38
+ text: videoBlock(video, args.detail) + note,
39
+ structured: video,
40
+ count: 1,
41
+ cacheHit,
42
+ images,
43
+ };
44
+ }));
45
+ }
46
+ //# sourceMappingURL=get-video.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-video.js","sourceRoot":"","sources":["../../src/tools/get-video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AK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAE/C,MAAM,MAAM,GAAsB,EAAE,CAAC;QACrC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;YAClE,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,IAAI,GAAG,0EAA0E,CAAC;YACpF,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QAED,OAAO;YACL,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI;YAC3C,UAAU,EAAE,KAA2C;YACvD,KAAK,EAAE,CAAC;YACR,QAAQ;YACR,MAAM;SACP,CAAC;IACJ,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { ToolError, textResult, toolErrorResult } from '../errors.js';
2
+ import { log } from '../log.js';
3
+ /**
4
+ * One place for tool bookkeeping: timing, structured logging, and turning any
5
+ * thrown value into a tool result with `isError: true` (never a protocol error).
6
+ */
7
+ export async function runTool(name, work) {
8
+ const started = Date.now();
9
+ try {
10
+ const outcome = await work();
11
+ log('info', 'tool_call', {
12
+ tool: name,
13
+ durationMs: Date.now() - started,
14
+ count: outcome.count,
15
+ cacheHit: outcome.cacheHit,
16
+ images: outcome.images?.length,
17
+ });
18
+ return textResult(outcome.text, outcome.structured, outcome.images);
19
+ }
20
+ catch (error) {
21
+ log('error', 'tool_error', {
22
+ tool: name,
23
+ durationMs: Date.now() - started,
24
+ code: error instanceof ToolError ? error.code : 'INTERNAL',
25
+ });
26
+ return toolErrorResult(error);
27
+ }
28
+ }
29
+ export const READ_ONLY_ANNOTATIONS = {
30
+ readOnlyHint: true,
31
+ openWorldHint: true,
32
+ };
33
+ export const SEARCH_HINTS = [
34
+ 'drop the color filter if you set one',
35
+ 'use fewer or more general words',
36
+ 'check the orientation and size filters',
37
+ ];
38
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/tools/helpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAwB,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAiBhC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,IAAY,EACZ,IAAgC;IAEhC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,IAAI,EAAE,CAAC;QAC7B,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE;YACvB,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO;YAChC,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM;SAC/B,CAAC,CAAC;QACH,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACtE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,OAAO,EAAE,YAAY,EAAE;YACzB,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO;YAChC,IAAI,EAAE,KAAK,YAAY,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU;SAC3D,CAAC,CAAC;QACH,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,IAAI;CACX,CAAC;AAEX,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,sCAAsC;IACtC,iCAAiC;IACjC,wCAAwC;CAChC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { registerCollectionMedia } from './collection-media.js';
2
+ import { registerCuratedPhotos } from './curated-photos.js';
3
+ import { registerFeaturedCollections } from './featured-collections.js';
4
+ import { registerGetPhoto } from './get-photo.js';
5
+ import { registerGetVideo } from './get-video.js';
6
+ import { registerPhotoUrl } from './photo-url.js';
7
+ import { registerPopularVideos } from './popular-videos.js';
8
+ import { registerSearchPhotos } from './search-photos.js';
9
+ import { registerSearchVideos } from './search-videos.js';
10
+ export function registerTools(server, ctx) {
11
+ registerSearchPhotos(server, ctx);
12
+ registerCuratedPhotos(server, ctx);
13
+ registerGetPhoto(server, ctx);
14
+ registerPhotoUrl(server, ctx);
15
+ registerSearchVideos(server, ctx);
16
+ registerPopularVideos(server, ctx);
17
+ registerGetVideo(server, ctx);
18
+ registerFeaturedCollections(server, ctx);
19
+ registerCollectionMedia(server, ctx);
20
+ }
21
+ //# sourceMappingURL=index.js.map