Overview

Use the Music MCP server from your ATXP-powered agent to create music from a natural-language prompt.

Example prompts

  • “Create a modern country song about a cat riding a horse.”
  • “Create an electronic dance music song about a child and a puppy.”

Tools

Usage

1

Define the Music service

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.
const musicService = {
    mcpServer: 'https://music.mcp.atxp.ai/',
    createMusicToolName: 'music_create_music',
    description: 'ATXP Music MCP server',
    getArguments: (prompt: string, lyrics: string) => ({ prompt, lyrics }),
    getResult: (result: any) => {
      const jsonResult = result.content[0].text
      return JSON.parse(jsonResult);
    }
  };
2

Create an ATXP client

Create a client using an ATXP account by importing the ATXP client SDK and other dependencies.
// Import the ATXP client SDK
import { atxpClient, ATXPAccount } from '@atxp/client';

// Read the ATXP account details from environment variables
const atxpConnectionString = process.env.ATXP_CONNECTION;

// Create a client using the `atxpClient` function
const 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.
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.