search
Find and add movies or TV series to your media library by searching across connected streaming and management services.
Instructions
Search for media (series/movies) to add
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| query | Yes | ||
| service | Yes |
Implementation Reference
- src/index.ts:87-99 (registration)Registration of the 'search' tool in the MCP tools list, including name, description, and input schema.{ name: "search", description: "Search for media (series/movies) to add", inputSchema: { type: "object", properties: { service: { type: "string" }, query: { type: "string" }, limit: { type: "number" }, }, required: ["service", "query"], }, },
- src/index.ts:298-307 (handler)Dispatch handler in the main tool request handler that calls the service-specific search method.case "search": if (!input.query) { throw new McpError( ErrorCode.InvalidParams, "Missing query parameter", ); } return await service.search(input.query, { limit: input.limit, });
- src/services/shared.ts:354-396 (handler)Core implementation of the search tool logic in BaseArrService, querying the *arr API lookup endpoint and mapping results to standardized SearchData.async search( query: string, options: SearchOptions = {}, ): Promise<OperationResult<SearchData>> { debugOperation(this.serviceName, "search", { query: query.substring(0, 50), limit: options.limit, }); try { const limit = options.limit || 10; const params = { term: query }; const response: SearchResponse = await fetchJson( this.buildApiUrl(this.endpoints.lookup, params), ); const results = Array.isArray(response) ? response : []; const limitedResults = results.slice(0, limit); const searchResults = limitedResults.map((item: SearchRecord) => ({ id: this.id === "sonarr" ? item.tvdbId : item.tmdbId, title: item.title, year: item.year, overview: item.overview, mediaKind: this.mediaKind, foreignId: this.id === "sonarr" ? item.tvdbId : item.tmdbId, imdbId: item.imdbId, })); return { ok: true, data: { service: this.serviceName, mediaKind: this.mediaKind, total: results.length, results: searchResults, truncated: results.length > limit, }, }; } catch (error) { return handleError(error, this.serviceName); } } async addNew(request: AddRequest): Promise<OperationResult<AddData>> {
- src/services/base.ts:104-124 (schema)Type definitions for SearchOptions, SearchResult, and SearchData used by the search tool.export interface SearchOptions { limit?: number; } export interface SearchResult { id?: number; title: string; year?: number; overview?: string; mediaKind: "series" | "movie"; foreignId?: number; imdbId?: string; } export interface SearchData { service: string; mediaKind: "series" | "movie"; total: number; results: SearchResult[]; truncated: boolean; }
- src/services/base.ts:249-252 (schema)Interface definition for the search method in ServiceImplementation.search( query: string, options?: SearchOptions, ): Promise<OperationResult<SearchData>>;