@orellbuehler/sonarr-mcp 0.1.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.
@@ -0,0 +1,129 @@
1
+ import { z } from "zod";
2
+ import { buildQS, ok, err, pruneUndefined, summarizeEpisode, } from "../sonarr/format.js";
3
+ export function registerEpisodeTools(server, client) {
4
+ server.tool("list_episodes", "List episodes as compact summaries (id, season/episode number, title, air date, hasFile, monitored). Filter by series, season or episode file. Use get_episode for the full object.", {
5
+ series_id: z.number().optional().describe("Only episodes of this Sonarr series id"),
6
+ season_number: z
7
+ .number()
8
+ .optional()
9
+ .describe("Only this season number (0 is specials); requires series_id"),
10
+ episode_ids: z.array(z.number()).optional().describe("Fetch these specific episode ids"),
11
+ episode_file_id: z
12
+ .number()
13
+ .optional()
14
+ .describe("Only episodes linked to this episode file id"),
15
+ include_series: z.boolean().optional().describe("Include the parent series object"),
16
+ include_episode_file: z.boolean().optional().describe("Include the episode file object"),
17
+ missing_only: z.boolean().optional().describe("Only episodes without a file (hasFile false)"),
18
+ monitored: z.boolean().optional().describe("Only monitored (true) or unmonitored (false)"),
19
+ detailed: z.boolean().optional().describe("Return full episode objects instead of summaries"),
20
+ }, async ({ series_id, season_number, episode_ids, episode_file_id, include_series, include_episode_file, missing_only, monitored, detailed, }) => {
21
+ try {
22
+ const qs = buildQS({
23
+ seriesId: series_id,
24
+ seasonNumber: season_number,
25
+ episodeIds: episode_ids,
26
+ episodeFileId: episode_file_id,
27
+ includeSeries: include_series,
28
+ includeEpisodeFile: include_episode_file,
29
+ });
30
+ let rows = (await client.get(`/api/v3/episode${qs}`));
31
+ if (missing_only)
32
+ rows = rows.filter((e) => !e.hasFile);
33
+ if (monitored !== undefined)
34
+ rows = rows.filter((e) => e.monitored === monitored);
35
+ return ok({
36
+ count: rows.length,
37
+ episodes: detailed ? rows : rows.map(summarizeEpisode),
38
+ });
39
+ }
40
+ catch (e) {
41
+ return err(e);
42
+ }
43
+ });
44
+ server.tool("get_episode", "Get the full episode object, including the overview and the linked episode file with its quality and media info.", { id: z.number().describe("Sonarr episode id") }, async ({ id }) => {
45
+ try {
46
+ return ok(await client.get(`/api/v3/episode/${id}`));
47
+ }
48
+ catch (e) {
49
+ return err(e);
50
+ }
51
+ });
52
+ server.tool("set_episodes_monitored", "Monitor or unmonitor individual episodes. Use set_season_monitored for whole seasons.", {
53
+ episode_ids: z.array(z.number()).describe("Sonarr episode ids"),
54
+ monitored: z.boolean().describe("true to monitor, false to unmonitor"),
55
+ }, async ({ episode_ids, monitored }) => {
56
+ try {
57
+ return ok(await client.put("/api/v3/episode/monitor", { episodeIds: episode_ids, monitored }));
58
+ }
59
+ catch (e) {
60
+ return err(e);
61
+ }
62
+ });
63
+ server.tool("list_episode_files", "List episode files on disk for a series, with path, size, quality, languages and release group.", {
64
+ series_id: z.number().optional().describe("Sonarr series id"),
65
+ episode_file_ids: z.array(z.number()).optional().describe("Fetch these specific file ids"),
66
+ }, async ({ series_id, episode_file_ids }) => {
67
+ try {
68
+ const data = (await client.get(`/api/v3/episodefile${buildQS({
69
+ seriesId: series_id,
70
+ episodeFileIds: episode_file_ids,
71
+ })}`));
72
+ return ok({ count: data.length, files: data });
73
+ }
74
+ catch (e) {
75
+ return err(e);
76
+ }
77
+ });
78
+ server.tool("get_episode_file", "Get a single episode file, including its full media info.", { id: z.number().describe("Episode file id") }, async ({ id }) => {
79
+ try {
80
+ return ok(await client.get(`/api/v3/episodefile/${id}`));
81
+ }
82
+ catch (e) {
83
+ return err(e);
84
+ }
85
+ });
86
+ server.tool("delete_episode_file", "Delete one episode file from disk. The episode stays in the library and becomes missing.", { id: z.number().describe("Episode file id") }, async ({ id }) => {
87
+ try {
88
+ return ok(await client.delete(`/api/v3/episodefile/${id}`));
89
+ }
90
+ catch (e) {
91
+ return err(e);
92
+ }
93
+ });
94
+ server.tool("delete_episode_files", "Delete several episode files from disk in one call.", { episode_file_ids: z.array(z.number()).describe("Episode file ids to delete") }, async ({ episode_file_ids }) => {
95
+ try {
96
+ return ok(await client.delete("/api/v3/episodefile/bulk", { episodeFileIds: episode_file_ids }));
97
+ }
98
+ catch (e) {
99
+ return err(e);
100
+ }
101
+ });
102
+ server.tool("update_episode_files", "Change the recorded quality, languages, release group or scene name of existing episode files (the file editor). Does not touch the files on disk.", {
103
+ episode_file_ids: z.array(z.number()).describe("Episode file ids to update"),
104
+ quality: z
105
+ .record(z.unknown())
106
+ .optional()
107
+ .describe("QualityModel object, e.g. { quality: { id: 9 }, revision: { version: 1 } }"),
108
+ languages: z
109
+ .array(z.record(z.unknown()))
110
+ .optional()
111
+ .describe("Language objects, e.g. [{ id: 1, name: 'English' }] — see list_languages"),
112
+ release_group: z.string().optional().describe("Release group to record"),
113
+ scene_name: z.string().optional().describe("Scene name to record"),
114
+ }, async ({ episode_file_ids, quality, languages, release_group, scene_name }) => {
115
+ try {
116
+ const body = pruneUndefined({
117
+ episodeFileIds: episode_file_ids,
118
+ quality,
119
+ languages,
120
+ releaseGroup: release_group,
121
+ sceneName: scene_name,
122
+ });
123
+ return ok(await client.put("/api/v3/episodefile/editor", body));
124
+ }
125
+ catch (e) {
126
+ return err(e);
127
+ }
128
+ });
129
+ }
@@ -0,0 +1,96 @@
1
+ import { z } from "zod";
2
+ import { buildQS, ok, err } from "../sonarr/format.js";
3
+ const eventTypes = [
4
+ "unknown",
5
+ "grabbed",
6
+ "seriesFolderImported",
7
+ "downloadFolderImported",
8
+ "downloadFailed",
9
+ "episodeFileDeleted",
10
+ "episodeFileRenamed",
11
+ "downloadIgnored",
12
+ ];
13
+ const sortDirection = ["default", "ascending", "descending"];
14
+ export function registerHistoryTools(server, client) {
15
+ server.tool("get_history", "Page through the grab and import history — what was grabbed, imported, failed, deleted or renamed, and from which indexer.", {
16
+ page: z.number().optional().describe("Page number (default 1)"),
17
+ page_size: z.number().optional().describe("Items per page (default 10 on the Sonarr side)"),
18
+ sort_key: z.string().optional().describe("Field to sort by, e.g. 'date'"),
19
+ sort_direction: z.enum(sortDirection).optional().describe("Sort direction"),
20
+ event_type: z.array(z.enum(eventTypes)).optional().describe("Only these event types"),
21
+ episode_id: z.number().optional().describe("Only history for this episode id"),
22
+ series_ids: z.array(z.number()).optional().describe("Only history for these series ids"),
23
+ download_id: z.string().optional().describe("Only history for this download client id"),
24
+ include_series: z.boolean().optional().describe("Include the parent series object"),
25
+ include_episode: z.boolean().optional().describe("Include the episode object"),
26
+ }, async ({ page, page_size, sort_key, sort_direction, event_type, episode_id, series_ids, download_id, include_series, include_episode, }) => {
27
+ try {
28
+ const qs = buildQS({
29
+ page,
30
+ pageSize: page_size,
31
+ sortKey: sort_key,
32
+ sortDirection: sort_direction,
33
+ eventType: event_type,
34
+ episodeId: episode_id,
35
+ seriesIds: series_ids,
36
+ downloadId: download_id,
37
+ includeSeries: include_series,
38
+ includeEpisode: include_episode,
39
+ });
40
+ return ok(await client.get(`/api/v3/history${qs}`));
41
+ }
42
+ catch (e) {
43
+ return err(e);
44
+ }
45
+ });
46
+ server.tool("get_history_since", "Get every history record since a date, unpaged. Useful for 'what happened since yesterday' style questions.", {
47
+ date: z.string().describe("ISO 8601 date or timestamp, e.g. '2026-09-01'"),
48
+ event_type: z.enum(eventTypes).optional().describe("Only this event type"),
49
+ include_series: z.boolean().optional().describe("Include the parent series object"),
50
+ include_episode: z.boolean().optional().describe("Include the episode object"),
51
+ }, async ({ date, event_type, include_series, include_episode }) => {
52
+ try {
53
+ const qs = buildQS({
54
+ date,
55
+ eventType: event_type,
56
+ includeSeries: include_series,
57
+ includeEpisode: include_episode,
58
+ });
59
+ const data = (await client.get(`/api/v3/history/since${qs}`));
60
+ return ok({ count: data.length, records: data });
61
+ }
62
+ catch (e) {
63
+ return err(e);
64
+ }
65
+ });
66
+ server.tool("get_series_history", "Get the full history for one series, optionally narrowed to a single season.", {
67
+ series_id: z.number().describe("Sonarr series id"),
68
+ season_number: z.number().optional().describe("Only this season number"),
69
+ event_type: z.enum(eventTypes).optional().describe("Only this event type"),
70
+ include_series: z.boolean().optional().describe("Include the parent series object"),
71
+ include_episode: z.boolean().optional().describe("Include the episode object"),
72
+ }, async ({ series_id, season_number, event_type, include_series, include_episode }) => {
73
+ try {
74
+ const qs = buildQS({
75
+ seriesId: series_id,
76
+ seasonNumber: season_number,
77
+ eventType: event_type,
78
+ includeSeries: include_series,
79
+ includeEpisode: include_episode,
80
+ });
81
+ const data = (await client.get(`/api/v3/history/series${qs}`));
82
+ return ok({ count: data.length, records: data });
83
+ }
84
+ catch (e) {
85
+ return err(e);
86
+ }
87
+ });
88
+ server.tool("mark_history_item_failed", "Mark a grabbed history item as failed. Sonarr blocklists the release and searches for a replacement.", { id: z.number().describe("History record id") }, async ({ id }) => {
89
+ try {
90
+ return ok(await client.post(`/api/v3/history/failed/${id}`));
91
+ }
92
+ catch (e) {
93
+ return err(e);
94
+ }
95
+ });
96
+ }
@@ -0,0 +1,158 @@
1
+ import { z } from "zod";
2
+ import { buildQS, ok, err } from "../sonarr/format.js";
3
+ export function registerOrganizationTools(server, client) {
4
+ server.tool("list_root_folders", "List root folders with their free space and any unmapped folders sitting in them. add_series needs one of these paths.", {}, async () => {
5
+ try {
6
+ const data = (await client.get("/api/v3/rootfolder"));
7
+ return ok({
8
+ count: data.length,
9
+ rootFolders: data.map((f) => ({
10
+ id: f.id,
11
+ path: f.path,
12
+ accessible: f.accessible,
13
+ freeSpace: f.freeSpace,
14
+ unmappedFolderCount: (f.unmappedFolders ?? []).length,
15
+ })),
16
+ });
17
+ }
18
+ catch (e) {
19
+ return err(e);
20
+ }
21
+ });
22
+ server.tool("get_root_folder", "Get one root folder including the full list of unmapped folders — series folders on disk that are not in the library.", { id: z.number().describe("Root folder id") }, async ({ id }) => {
23
+ try {
24
+ return ok(await client.get(`/api/v3/rootfolder/${id}`));
25
+ }
26
+ catch (e) {
27
+ return err(e);
28
+ }
29
+ });
30
+ server.tool("add_root_folder", "Add a root folder. The path must exist and be writable by Sonarr.", { path: z.string().describe("Absolute path as Sonarr sees it, e.g. '/tv'") }, async ({ path }) => {
31
+ try {
32
+ return ok(await client.post("/api/v3/rootfolder", { path }));
33
+ }
34
+ catch (e) {
35
+ return err(e);
36
+ }
37
+ });
38
+ server.tool("delete_root_folder", "Remove a root folder from Sonarr. Files on disk are not touched.", { id: z.number().describe("Root folder id") }, async ({ id }) => {
39
+ try {
40
+ return ok(await client.delete(`/api/v3/rootfolder/${id}`));
41
+ }
42
+ catch (e) {
43
+ return err(e);
44
+ }
45
+ });
46
+ server.tool("list_tags", "List tags with their ids and labels. Tags link series to delay profiles, release profiles, indexers and notifications.", {}, async () => {
47
+ try {
48
+ const data = (await client.get("/api/v3/tag"));
49
+ return ok({ count: data.length, tags: data });
50
+ }
51
+ catch (e) {
52
+ return err(e);
53
+ }
54
+ });
55
+ server.tool("list_tag_details", "List tags together with everything using them — series ids, indexer ids, notification ids and profile ids.", {}, async () => {
56
+ try {
57
+ const data = (await client.get("/api/v3/tag/detail"));
58
+ return ok({ count: data.length, tags: data });
59
+ }
60
+ catch (e) {
61
+ return err(e);
62
+ }
63
+ });
64
+ server.tool("create_tag", "Create a tag.", { label: z.string().describe("Tag label, e.g. 'anime'") }, async ({ label }) => {
65
+ try {
66
+ return ok(await client.post("/api/v3/tag", { label }));
67
+ }
68
+ catch (e) {
69
+ return err(e);
70
+ }
71
+ });
72
+ server.tool("update_tag", "Rename a tag.", {
73
+ id: z.number().describe("Tag id"),
74
+ label: z.string().describe("New tag label"),
75
+ }, async ({ id, label }) => {
76
+ try {
77
+ return ok(await client.put(`/api/v3/tag/${id}`, { id, label }));
78
+ }
79
+ catch (e) {
80
+ return err(e);
81
+ }
82
+ });
83
+ server.tool("delete_tag", "Delete a tag. It is removed from every series and provider using it.", { id: z.number().describe("Tag id") }, async ({ id }) => {
84
+ try {
85
+ return ok(await client.delete(`/api/v3/tag/${id}`));
86
+ }
87
+ catch (e) {
88
+ return err(e);
89
+ }
90
+ });
91
+ server.tool("list_import_list_exclusions", "List series excluded from import lists — series that lists will never re-add.", {
92
+ page: z.number().optional().describe("Page number; unpaged when omitted"),
93
+ page_size: z.number().optional().describe("Items per page"),
94
+ }, async ({ page, page_size }) => {
95
+ try {
96
+ if (page !== undefined || page_size !== undefined) {
97
+ return ok(await client.get(`/api/v3/importlistexclusion/paged${buildQS({ page, pageSize: page_size })}`));
98
+ }
99
+ const data = (await client.get("/api/v3/importlistexclusion"));
100
+ return ok({ count: data.length, exclusions: data });
101
+ }
102
+ catch (e) {
103
+ return err(e);
104
+ }
105
+ });
106
+ server.tool("add_import_list_exclusion", "Exclude a series from import lists by TVDB id, so lists stop re-adding it.", {
107
+ tvdb_id: z.number().describe("TVDB id of the series to exclude"),
108
+ title: z.string().describe("Series title, for display in the Sonarr UI"),
109
+ }, async ({ tvdb_id, title }) => {
110
+ try {
111
+ return ok(await client.post("/api/v3/importlistexclusion", { tvdbId: tvdb_id, title }));
112
+ }
113
+ catch (e) {
114
+ return err(e);
115
+ }
116
+ });
117
+ server.tool("delete_import_list_exclusion", "Remove an import list exclusion so lists may add the series again.", { id: z.number().describe("Import list exclusion id") }, async ({ id }) => {
118
+ try {
119
+ return ok(await client.delete(`/api/v3/importlistexclusion/${id}`));
120
+ }
121
+ catch (e) {
122
+ return err(e);
123
+ }
124
+ });
125
+ server.tool("list_remote_path_mappings", "List remote path mappings — how paths reported by a download client on another host translate to paths Sonarr can read.", {}, async () => {
126
+ try {
127
+ const data = (await client.get("/api/v3/remotepathmapping"));
128
+ return ok({ count: data.length, mappings: data });
129
+ }
130
+ catch (e) {
131
+ return err(e);
132
+ }
133
+ });
134
+ server.tool("add_remote_path_mapping", "Add a remote path mapping for a download client host.", {
135
+ host: z.string().describe("Download client host as configured in Sonarr"),
136
+ remote_path: z.string().describe("Path as the download client reports it"),
137
+ local_path: z.string().describe("Matching path as Sonarr sees it"),
138
+ }, async ({ host, remote_path, local_path }) => {
139
+ try {
140
+ return ok(await client.post("/api/v3/remotepathmapping", {
141
+ host,
142
+ remotePath: remote_path,
143
+ localPath: local_path,
144
+ }));
145
+ }
146
+ catch (e) {
147
+ return err(e);
148
+ }
149
+ });
150
+ server.tool("delete_remote_path_mapping", "Delete a remote path mapping.", { id: z.number().describe("Remote path mapping id") }, async ({ id }) => {
151
+ try {
152
+ return ok(await client.delete(`/api/v3/remotepathmapping/${id}`));
153
+ }
154
+ catch (e) {
155
+ return err(e);
156
+ }
157
+ });
158
+ }
@@ -0,0 +1,203 @@
1
+ import { z } from "zod";
2
+ import { ok, err } from "../sonarr/format.js";
3
+ export function registerProfileTools(server, client) {
4
+ server.tool("list_quality_profiles", "List quality profiles with their id, name, cutoff and the qualities each one allows. Series are assigned a profile by id.", {
5
+ detailed: z
6
+ .boolean()
7
+ .optional()
8
+ .describe("Include the full items and formatItems arrays (large payload)"),
9
+ }, async ({ detailed }) => {
10
+ try {
11
+ const data = (await client.get("/api/v3/qualityprofile"));
12
+ if (detailed)
13
+ return ok({ count: data.length, profiles: data });
14
+ return ok({
15
+ count: data.length,
16
+ profiles: data.map((p) => ({
17
+ id: p.id,
18
+ name: p.name,
19
+ upgradeAllowed: p.upgradeAllowed,
20
+ cutoff: p.cutoff,
21
+ minFormatScore: p.minFormatScore,
22
+ cutoffFormatScore: p.cutoffFormatScore,
23
+ allowedQualities: (p.items ?? [])
24
+ .filter((i) => i.allowed)
25
+ .map((i) => i.name ?? i.quality?.name ?? ""),
26
+ })),
27
+ });
28
+ }
29
+ catch (e) {
30
+ return err(e);
31
+ }
32
+ });
33
+ server.tool("get_quality_profile", "Get one quality profile in full, including every quality item and custom format score.", { id: z.number().describe("Quality profile id") }, async ({ id }) => {
34
+ try {
35
+ return ok(await client.get(`/api/v3/qualityprofile/${id}`));
36
+ }
37
+ catch (e) {
38
+ return err(e);
39
+ }
40
+ });
41
+ server.tool("get_quality_profile_schema", "Get a blank quality profile with every quality Sonarr knows about — the template for create_quality_profile.", {}, async () => {
42
+ try {
43
+ return ok(await client.get("/api/v3/qualityprofile/schema"));
44
+ }
45
+ catch (e) {
46
+ return err(e);
47
+ }
48
+ });
49
+ server.tool("create_quality_profile", "Create a quality profile. Start from get_quality_profile_schema, set name, cutoff and which items are allowed.", { profile: z.record(z.unknown()).describe("Full quality profile object") }, async ({ profile }) => {
50
+ try {
51
+ return ok(await client.post("/api/v3/qualityprofile", profile));
52
+ }
53
+ catch (e) {
54
+ return err(e);
55
+ }
56
+ });
57
+ server.tool("update_quality_profile", "Update a quality profile. Fetch it with get_quality_profile, change what you need and send the whole object back.", {
58
+ id: z.number().describe("Quality profile id"),
59
+ profile: z.record(z.unknown()).describe("Full quality profile object including id"),
60
+ }, async ({ id, profile }) => {
61
+ try {
62
+ return ok(await client.put(`/api/v3/qualityprofile/${id}`, { ...profile, id }));
63
+ }
64
+ catch (e) {
65
+ return err(e);
66
+ }
67
+ });
68
+ server.tool("delete_quality_profile", "Delete a quality profile. It must not be in use by any series.", { id: z.number().describe("Quality profile id") }, async ({ id }) => {
69
+ try {
70
+ return ok(await client.delete(`/api/v3/qualityprofile/${id}`));
71
+ }
72
+ catch (e) {
73
+ return err(e);
74
+ }
75
+ });
76
+ server.tool("list_quality_definitions", "List quality definitions — the size limits (min, max, preferred MB per minute) Sonarr applies to each quality.", {}, async () => {
77
+ try {
78
+ const data = (await client.get("/api/v3/qualitydefinition"));
79
+ return ok({ count: data.length, definitions: data });
80
+ }
81
+ catch (e) {
82
+ return err(e);
83
+ }
84
+ });
85
+ server.tool("update_quality_definitions", "Update the size limits of one or more quality definitions. Send the full definition objects from list_quality_definitions with minSize, maxSize or preferredSize changed.", {
86
+ definitions: z
87
+ .array(z.record(z.unknown()))
88
+ .describe("Full quality definition objects including id"),
89
+ }, async ({ definitions }) => {
90
+ try {
91
+ return ok(await client.put("/api/v3/qualitydefinition/update", definitions));
92
+ }
93
+ catch (e) {
94
+ return err(e);
95
+ }
96
+ });
97
+ server.tool("list_custom_formats", "List custom formats with their specifications. Custom format scores in a quality profile decide which releases are preferred.", {}, async () => {
98
+ try {
99
+ const data = (await client.get("/api/v3/customformat"));
100
+ return ok({ count: data.length, customFormats: data });
101
+ }
102
+ catch (e) {
103
+ return err(e);
104
+ }
105
+ });
106
+ server.tool("get_custom_format", "Get one custom format with its full specification list.", { id: z.number().describe("Custom format id") }, async ({ id }) => {
107
+ try {
108
+ return ok(await client.get(`/api/v3/customformat/${id}`));
109
+ }
110
+ catch (e) {
111
+ return err(e);
112
+ }
113
+ });
114
+ server.tool("get_custom_format_schema", "List the specification types a custom format can use (release title regex, size, language, quality modifier, ...) with their fields.", {}, async () => {
115
+ try {
116
+ return ok(await client.get("/api/v3/customformat/schema"));
117
+ }
118
+ catch (e) {
119
+ return err(e);
120
+ }
121
+ });
122
+ server.tool("create_custom_format", "Create a custom format. Build the specifications from get_custom_format_schema.", { custom_format: z.record(z.unknown()).describe("Full custom format object") }, async ({ custom_format }) => {
123
+ try {
124
+ return ok(await client.post("/api/v3/customformat", custom_format));
125
+ }
126
+ catch (e) {
127
+ return err(e);
128
+ }
129
+ });
130
+ server.tool("update_custom_format", "Update a custom format. Fetch it first and send the whole object back.", {
131
+ id: z.number().describe("Custom format id"),
132
+ custom_format: z.record(z.unknown()).describe("Full custom format object including id"),
133
+ }, async ({ id, custom_format }) => {
134
+ try {
135
+ return ok(await client.put(`/api/v3/customformat/${id}`, { ...custom_format, id }));
136
+ }
137
+ catch (e) {
138
+ return err(e);
139
+ }
140
+ });
141
+ server.tool("delete_custom_format", "Delete a custom format.", { id: z.number().describe("Custom format id") }, async ({ id }) => {
142
+ try {
143
+ return ok(await client.delete(`/api/v3/customformat/${id}`));
144
+ }
145
+ catch (e) {
146
+ return err(e);
147
+ }
148
+ });
149
+ server.tool("list_release_profiles", "List release profiles — the required, ignored and preferred term rules applied to release titles.", {}, async () => {
150
+ try {
151
+ const data = (await client.get("/api/v3/releaseprofile"));
152
+ return ok({ count: data.length, releaseProfiles: data });
153
+ }
154
+ catch (e) {
155
+ return err(e);
156
+ }
157
+ });
158
+ server.tool("create_release_profile", "Create a release profile, e.g. { name, enabled: true, required: [], ignored: ['x265'], indexerId: 0, tags: [] }.", { release_profile: z.record(z.unknown()).describe("Full release profile object") }, async ({ release_profile }) => {
159
+ try {
160
+ return ok(await client.post("/api/v3/releaseprofile", release_profile));
161
+ }
162
+ catch (e) {
163
+ return err(e);
164
+ }
165
+ });
166
+ server.tool("update_release_profile", "Update a release profile. Fetch it from list_release_profiles and send the whole object back.", {
167
+ id: z.number().describe("Release profile id"),
168
+ release_profile: z.record(z.unknown()).describe("Full release profile object including id"),
169
+ }, async ({ id, release_profile }) => {
170
+ try {
171
+ return ok(await client.put(`/api/v3/releaseprofile/${id}`, { ...release_profile, id }));
172
+ }
173
+ catch (e) {
174
+ return err(e);
175
+ }
176
+ });
177
+ server.tool("delete_release_profile", "Delete a release profile.", { id: z.number().describe("Release profile id") }, async ({ id }) => {
178
+ try {
179
+ return ok(await client.delete(`/api/v3/releaseprofile/${id}`));
180
+ }
181
+ catch (e) {
182
+ return err(e);
183
+ }
184
+ });
185
+ server.tool("list_delay_profiles", "List delay profiles — how long Sonarr waits for a better release before grabbing, per protocol and tag.", {}, async () => {
186
+ try {
187
+ const data = (await client.get("/api/v3/delayprofile"));
188
+ return ok({ count: data.length, delayProfiles: data });
189
+ }
190
+ catch (e) {
191
+ return err(e);
192
+ }
193
+ });
194
+ server.tool("list_languages", "List the languages Sonarr knows, with the ids used in language profiles and episode file edits.", {}, async () => {
195
+ try {
196
+ const data = (await client.get("/api/v3/language"));
197
+ return ok({ count: data.length, languages: data });
198
+ }
199
+ catch (e) {
200
+ return err(e);
201
+ }
202
+ });
203
+ }