Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/mcp/tools/spotify/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { registerGetSpotifySearchTool } from "./registerGetSpotifySearchTool";
import { registerGetSpotifyArtistTopTracksTool } from "./registerGetSpotifyArtistTopTracksTool";
import { registerGetSpotifyArtistAlbumsTool } from "./registerGetSpotifyArtistAlbumsTool";
import { registerGetSpotifyAlbumTool } from "./registerGetSpotifyAlbumTool";
import { registerGetSpotifyDeepResearchTool } from "./registerGetSpotifyDeepResearchTool";

/**
* Registers all Spotify-related MCP tools on the server.
Expand All @@ -14,4 +15,5 @@ export const registerAllSpotifyTools = (server: McpServer): void => {
registerGetSpotifyArtistTopTracksTool(server);
registerGetSpotifyArtistAlbumsTool(server);
registerGetSpotifyAlbumTool(server);
registerGetSpotifyDeepResearchTool(server);
};
77 changes: 77 additions & 0 deletions lib/mcp/tools/spotify/registerGetSpotifyDeepResearchTool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";
import { getArtistSocials } from "@/lib/artist/getArtistSocials";
import { getToolResultSuccess } from "@/lib/mcp/getToolResultSuccess";
import { getToolResultError } from "@/lib/mcp/getToolResultError";

const SPOTIFY_DEEP_RESEARCH_REQUIREMENTS = `
- popularity info (MANDATORY):
* Track popularity scores (0-100) for all tracks
* Average popularity across all tracks
* Most popular tracks ranked by popularity
* Popularity trends over time (if available)
- Spotify follower metrics (MANDATORY):
* Current total follower count for the artist on Spotify
- engagement info
- tracklist
- collaborators
- album art
- album name
`;

// Zod schema for the MCP tool - matches the original tool interface
const getSpotifyDeepResearchSchema = z.object({
artist_account_id: z.string().min(1, "Artist account ID is required"),
});

type GetSpotifyDeepResearchArgs = z.infer<typeof getSpotifyDeepResearchSchema>;

/**
* Registers the "spotify_deep_research" tool on the MCP server.
* Performs deep research on an artist using a Spotify ID.
*
* @param server - The MCP server instance to register the tool on.
*/
export function registerGetSpotifyDeepResearchTool(server: McpServer): void {
server.registerTool(
"spotify_deep_research",
{
description: `Performs deep research on an artist using a Spotify ID.

Required items in deep research document:
${SPOTIFY_DEEP_RESEARCH_REQUIREMENTS}`,
Comment thread
sweetmantech marked this conversation as resolved.
inputSchema: getSpotifyDeepResearchSchema,
},
async (args: GetSpotifyDeepResearchArgs) => {
try {
// Call getArtistSocials with default pagination (page 1, limit 20)
const result = await getArtistSocials({
artist_account_id: args.artist_account_id,
page: 1,
limit: 20,
});

if (result.status === "error") {
return getToolResultError(result.message || "Failed to fetch artist socials");
}

// Format response to match the original tool's expected structure
const response = {
success: true,
artistSocials: {
socials: result.socials,
},
artist_account_id: args.artist_account_id,
pagination: result.pagination,
};

return getToolResultSuccess(response);
} catch (error) {
console.error("Error performing Spotify deep research:", error);
return getToolResultError(
error instanceof Error ? error.message : "Failed to perform Spotify deep research",
);
}
},
);
}