install_to_user_dir
Copy default sound files to user configuration directory for customization, setup, or troubleshooting missing audio files.
Instructions
Install sound files to user's config directory.
WHEN TO USE THIS TOOL:
- When the user wants to customize the sound files
- When setting up the sound tool for the first time
- When troubleshooting missing sound files
This tool copies the default sound files to the user's configuration directory
where they can be modified or replaced with custom sounds.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/sound_tool/server.py:196-201 (handler)Handler function that executes the tool logic by calling the copy helper and returning the result message.def install_to_user_dir() -> str: try: user_dir = self.copy_sounds_to_user_dir() return f"Sound files installed to {user_dir}" except Exception as e: return f"Error installing sound files: {e}"
- JSON schema definition for the install_to_user_dir tool, including name, description, parameters (none), and return type.install_tool_definition = { "name": "install_to_user_dir", "description": """ Install sound files to user's config directory. This tool should be used when the user wants to install the default sound files to their config directory for customization. """, "parameters": { "type": "object", "properties": {}, "required": [] }, "returns": { "type": "string", "description": "A message indicating the result of the operation" } }
- src/sound_tool/server.py:185-201 (registration)Tool registration via @mcp.tool decorator, including schema description, attached to the handler function.@self.mcp.tool(description=""" Install sound files to user's config directory. WHEN TO USE THIS TOOL: - When the user wants to customize the sound files - When setting up the sound tool for the first time - When troubleshooting missing sound files This tool copies the default sound files to the user's configuration directory where they can be modified or replaced with custom sounds. """) def install_to_user_dir() -> str: try: user_dir = self.copy_sounds_to_user_dir() return f"Sound files installed to {user_dir}" except Exception as e: return f"Error installing sound files: {e}"
- src/sound_tool/server.py:93-116 (helper)Supporting helper function that copies the sound files from package resources to the user's configuration directory.def copy_sounds_to_user_dir(self): """Copy bundled sounds to user config directory.""" user_sounds_dir = os.path.join(os.path.expanduser("~"), ".config", "mcp-sound-tool", "sounds") os.makedirs(user_sounds_dir, exist_ok=True) # Get list of sound files try: # Try with Python 3.9+ method sound_files = resources.files("sound_tool").joinpath("sounds").iterdir() for sound_file in sound_files: if sound_file.name.endswith((".mp3", ".wav")): shutil.copy(sound_file, os.path.join(user_sounds_dir, sound_file.name)) except (AttributeError, ImportError): # Fallback for older Python sounds_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "sounds") if os.path.exists(sounds_dir): for sound_file in os.listdir(sounds_dir): if sound_file.endswith((".mp3", ".wav")): shutil.copy( os.path.join(sounds_dir, sound_file), os.path.join(user_sounds_dir, sound_file) ) return user_sounds_dir