download_from_url
Download audio files from URLs for analysis in the MCP audio analysis server. Provides file paths for processing without revealing song names.
Instructions
Downloads a file from a given URL and returns the path to the downloaded file. Be careful, you will never know the name of the song.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes |
Implementation Reference
- src/mcp_music_analysis/server.py:200-218 (handler)The main implementation of the download_from_url tool. It downloads the audio file from the provided URL using requests, checks if it's an audio file (.mp3 or .wav), saves it to a temporary directory, and returns the local file path. Registered via @mcp.tool() decorator.@mcp.tool() def download_from_url(url: str) -> str: """ Downloads a file from a given URL and returns the path to the downloaded file. Be careful, you will never know the name of the song. """ # mettre une exception si ce n'est pas un fichier audio ! if not url.endswith(".mp3") and not url.endswith(".wav"): raise ValueError(f"URL: {url} is not a valid audio file") response = requests.get(url) if response.status_code == 200: file_path = os.path.join(tempfile.gettempdir(), "downloaded_file") with open(file_path, "wb") as file: file.write(response.content) return file_path else: raise ValueError(f"Failed to download file from URL: {url}")
- The tool signature as listed in the analyze_audio prompt, defining input (url: str) and output (str)."- download_from_url(url: str) -> str\n"