Take in lyrics and prompt and produce a hex encoded MP3 file. An example prompt would be “polka, upbeat, fast”. Example lyrics would be “[intro]Hey there cowboy[verse]That’s a mighty fine horse you got[outro]”. The output will contain a URL to the MP3 file.
The lyrics you would like to include in the music. You can use new lines to separate verses. You can use [intro][verse][chorus][bridge][outro] to specify the structure of the song.
Create a reusable service configuration that points to the MCP server and standardizes how you pass arguments and read results. This lets your agent easily interact with the Music tools in a consistent manner.
Create a client using an ATXP account by importing the ATXP client SDK and other dependencies.
Copy
Ask AI
// Import the ATXP client SDKimport { atxpClient, ATXPAccount } from '@atxp/client';// Read the ATXP account details from environment variablesconst atxpConnectionString = process.env.ATXP_CONNECTION;// Create a client using the `atxpClient` functionconst client = await atxpClient({ mcpServer: musicService.mcpServer, account: new ATXPAccount(atxpConnectionString),});
3
Use the Music service in your agent
Call the Music tool by passing your natural-language instruction as the argument the getArguments method.Read the response using the getResult method.
Copy
Ask AI
const prompt = "polka, upbeat, fast";const lyrics = "[intro]Hey there cowboy[verse]That's a mighty fine horse you got[outro]";try { const result = await client.callTool({ name: musicService.createMusicToolName, arguments: musicService.getArguments(prompt, lyrics), }); const createMusicResult = musicService.getResult(result); console.log('Status:', createMusicResult.status); console.log('URL:', createMusicResult.url);} catch (error) { console.error(`Error with ${musicService.description}:`, error); process.exit(1);}
You should see the result of the music creation printed in your console.