hearthis-mcp 0.6.0 → 0.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0
4
+
5
+ - Link page (https://hearthis.at/@yourname/): `get_link_page` reads it - its links in order, hidden ones too, the picked
6
+ sounds and sets and how a sound opens -, `edit_link_page` sets the order, hides a link of the profile, adds or removes
7
+ links only this page has, picks sounds and sets and switches between playing on the page and opening on hearthis.at.
8
+ `get_link_page_stats` has its opens, clicks, plays, shares, clicked links, sources and countries over 7, 30 or 90 days.
9
+ - With an API key: reading the link page and its statistics needs *Read*, changing it *Upload and edit*.
10
+
3
11
  ## 0.6.0
4
12
 
5
13
  - Sign in with a personal API key: `HEARTHIS_API_KEY=htp_…` instead of the key pair, and `npx hearthis-mcp login` takes a
package/README.md CHANGED
@@ -34,9 +34,9 @@ The key decides what the assistant can do:
34
34
 
35
35
  | Right of the key | Tools |
36
36
  |---|---|
37
- | *Read* | browsing, searching, your feed, sets, private sounds and statistics |
37
+ | *Read* | browsing, searching, your feed, sets, private sounds, statistics and your link page |
38
38
  | *Likes, follows and comments* | likes, reposts, listen later, comments, reactions, follows, joining a group |
39
- | *Upload and edit* | uploads, editing and deleting sounds, sets and groups, your profile and badges, workflows and feed sync |
39
+ | *Upload and edit* | uploads, editing and deleting sounds, sets and groups, your profile, badges and link page, workflows and feed sync |
40
40
  | *Messages* | reading and answering your direct messages |
41
41
 
42
42
  A tool the key has no right for says which right it needs. A key works for accounts without a password (Google,
@@ -69,6 +69,7 @@ loses access; run `npx hearthis-mcp login` again.
69
69
  | Tracks | `get_track`, `get_track_stats`, `get_track_part`, `toggle_like`, `toggle_repost`, `set_listen_later`, `get_cast_url`, `post_comment`, `delete_comment`, `post_reaction`, `streaming_quality`, `copy_track_image` |
70
70
  | Own tracks | `upload_track`, `edit_track`, `delete_track`, `set_track_cover`, `remove_track_cover` |
71
71
  | Users | `get_user`, `edit_profile`, `toggle_follow`, `badge_settings`, `get_fan_subscriptions` |
72
+ | Link page | `get_link_page`, `edit_link_page`, `get_link_page_stats` |
72
73
  | Sets | `list_my_sets`, `get_set`, `add_to_set`, `edit_set`, `remove_from_set`, `delete_set` |
73
74
  | Groups | `list_groups`, `get_group`, `create_group`, `join_group`, `edit_group`, `group_track`, `group_approve`, `group_block`, `group_member_role`, `delete_group` |
74
75
  | Messages | `list_conversations`, `read_conversation`, `poll_messages`, `send_message`, `delete_conversation` |
package/dist/tools.js CHANGED
@@ -8,6 +8,8 @@ const flag = z.boolean().optional();
8
8
  const iso = z.string().optional().describe('ISO 8601 with UTC offset, e.g. 2026-07-01T20:00:00+02:00');
9
9
  const trackPath = (a, t, action = '') => `/${authorSegment(a)}/${segment(t)}/${action ? action + '/' : ''}`;
10
10
  const bit = (value) => (value === undefined ? undefined : value ? 1 : 0);
11
+ /** A list or an object as the JSON text a form field carries. */
12
+ const json = (value) => (value === undefined ? undefined : JSON.stringify(value));
11
13
  const invite = z.string().optional()
12
14
  .describe('Invitation of a private group: its share link https://hearthis.at/group/{id}/{name}/{secret}/ or just the secret');
13
15
  /** The secret of an invitation link, or the secret itself. */
@@ -430,6 +432,109 @@ export function registerTools(server, api) {
430
432
  kind: 'read',
431
433
  run: (args) => api.get('/fan_subscriptions.php', args),
432
434
  });
435
+ // Link page
436
+ tool('get_link_page', {
437
+ title: 'Link page',
438
+ description: 'The link page of the account - https://hearthis.at/@{profile}/, one public page with its links, sounds and sets: available ' +
439
+ '(false: the profile has none yet), url, sound_mode, the links in order with key, type, title, url and visible (hidden ones ' +
440
+ 'too) and the picked tracks and sets (empty: the page shows the five newest public ones). Its numbers: get_link_page_stats.',
441
+ input: {},
442
+ kind: 'read',
443
+ full: true,
444
+ run: async () => {
445
+ const account = await api.ensurePremium();
446
+ const profile = (await api.get(`/${authorSegment(account.permalink)}/`));
447
+ if (!profile?.linkpage) {
448
+ throw new ApiError('hearthis.at did not answer the link page of the account.', 502);
449
+ }
450
+ return profile.linkpage;
451
+ },
452
+ });
453
+ tool('edit_link_page', {
454
+ title: 'Edit link page',
455
+ description: 'Sets up the link page of the account - only the fields given change, and the page is public: a change shows at once. links is ' +
456
+ 'the whole list in its new order, as get_link_page gives it: a link of the profile as {key, visible} (visible false hides it), ' +
457
+ 'a link only this page has as {title, url}. Links of the profile that are left out show - one hidden before too -, own links ' +
458
+ 'that are left out are removed. Title and address of a profile link change with edit_profile. Ids that are no public sound ' +
459
+ 'or set of the account are left out. Answers the new link page, with not_saved when an entry of links was not taken.',
460
+ input: {
461
+ links: z
462
+ .array(z.object({
463
+ key: z.string().min(1).max(80).optional().describe('A link of the profile: its key from get_link_page'),
464
+ visible: flag.describe('A link of the profile: false hides it on the link page'),
465
+ title: z.string().max(80).optional().describe('An own link: its title, empty shows the host'),
466
+ url: z.string().min(1).max(600).optional().describe('An own link: its https address'),
467
+ }))
468
+ .max(120)
469
+ .optional()
470
+ .describe('All links in order; up to 30 own ones'),
471
+ tracks: z.array(z.number().int().positive()).max(20).optional().describe('Ids of own public sounds to show, in order; [] shows the five newest'),
472
+ sets: z.array(z.number().int().positive()).max(20).optional().describe('Ids of own public sets to show, in order; [] shows the five newest'),
473
+ sound_mode: z.enum(['play', 'open']).optional().describe('play: a sound plays on the page; open: it opens on hearthis.at'),
474
+ },
475
+ kind: 'write',
476
+ access: 'write',
477
+ full: true,
478
+ run: async ({ links, tracks, sets, sound_mode }) => {
479
+ if (links === undefined && tracks === undefined && sets === undefined && sound_mode === undefined) {
480
+ throw new ApiError('Give links, tracks, sets or sound_mode.', 400, 'invalid_input');
481
+ }
482
+ // The API drops an entry it cannot place without a word: what is neither a profile link nor an own one is refused
483
+ // here, what the API then left out (a key the profile does not have, an address it does not take) is named below
484
+ const entries = links?.map((link, index) => {
485
+ const own = link.key === undefined || link.key === 'custom';
486
+ if (own && !link.url) {
487
+ throw new ApiError(`links[${index}] needs the key of a profile link, or title and url for an own link.`, 400, 'invalid_input');
488
+ }
489
+ if (own && link.visible === false) {
490
+ throw new ApiError(`links[${index}] is an own link: it cannot be hidden - leave it out to remove it.`, 400, 'invalid_input');
491
+ }
492
+ return own ? { title: link.title ?? '', url: link.url } : { key: link.key, visible: link.visible ?? true };
493
+ });
494
+ const saved = (await api.post('/my/linkpage/', { links: json(entries), tracks: json(tracks), sets: json(sets), sound_mode }));
495
+ if (!entries || !saved || !Array.isArray(saved.links)) {
496
+ return saved;
497
+ }
498
+ const stored = saved.links.map((link) => link.key);
499
+ const unknown = entries.flatMap((entry) => (entry.key !== undefined && !stored.includes(entry.key) ? [entry.key] : []));
500
+ const ownMissing = entries.filter((entry) => entry.key === undefined).length - stored.filter((key) => key === 'custom').length;
501
+ if (unknown.length === 0 && ownMissing <= 0) {
502
+ return saved;
503
+ }
504
+ return {
505
+ ...saved,
506
+ not_saved: {
507
+ ...(unknown.length > 0 ? { unknown_keys: unknown } : {}),
508
+ ...(ownMissing > 0 ? { own_links: ownMissing } : {}),
509
+ note: 'hearthis.at left these out: a key that is no link of the profile (an own link goes without key, as title and url), ' +
510
+ 'an own link whose address it does not take, or the same address twice.',
511
+ },
512
+ };
513
+ },
514
+ });
515
+ tool('get_link_page_stats', {
516
+ title: 'Link page statistics',
517
+ description: 'Statistics of the link page over the last 7, 30 (default) or 90 days: opens, clicks, click_rate (clicks per 100 opens), plays, ' +
518
+ 'shares, the numbers per day, the clicked links, the sources and the countries of the visitors. Visitors who block tracking ' +
519
+ 'are not counted; up to 15 minutes old. partial: the period starts before the counting did (since is its first counted day).',
520
+ input: { days: z.union([z.literal(7), z.literal(30), z.literal(90)]).optional().describe('Period in days: 7, 30 or 90') },
521
+ kind: 'read',
522
+ full: true,
523
+ run: async ({ days }) => {
524
+ try {
525
+ return await api.get('/my/linkpage/stats/', { days });
526
+ }
527
+ catch (error) {
528
+ if (error instanceof ApiError && error.code === 'no_linkpage') {
529
+ throw new ApiError('The account has no link page yet: it needs a visible, verified profile with at least one upload.', 404, 'no_linkpage');
530
+ }
531
+ if (error instanceof ApiError && error.code === 'unavailable') {
532
+ throw new ApiError('hearthis.at cannot read the link page statistics right now - try again later.', 503, 'unavailable');
533
+ }
534
+ throw error;
535
+ }
536
+ },
537
+ });
433
538
  // Sets (playlists)
434
539
  tool('list_my_sets', {
435
540
  title: 'My sets',
@@ -767,7 +872,6 @@ export function registerTools(server, api) {
767
872
  }).describe(DEFINITION_HELP);
768
873
  const state = z.enum(['off', 'log', 'on'])
769
874
  .describe('off: does nothing by itself; log: test run - on new sounds it only writes down in the history what it would do; on: acts on new sounds');
770
- const json = (value) => (value === undefined ? undefined : JSON.stringify(value));
771
875
  const id = z.number().int().positive();
772
876
  tool('list_workflows', {
773
877
  title: 'List workflows',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hearthis-mcp",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "MCP server for hearthis.at - lets an AI assistant browse, upload, edit and message as your account (Premium members)",
5
5
  "keywords": [
6
6
  "mcp",