diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-09-13 14:12:41 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-09-13 14:13:04 +0900 |
| commit | 97b34627667fd699f4e0e054533eb89a205a2878 (patch) | |
| tree | 1d4549d56b7c53be9ecb583db9bb1a5593e54126 /src/mml_composemusic_mcp/synthesizer.py | |
| parent | 3b5bd2f8fd15bcc13542ff5ffd3c35453af9a9df (diff) | |
feat: return composed WAV as MCP audio content
Replace the server-local wav_path result with a protocol-native multimedia response.
- Split internal composition execution from MCP ToolResult serialization so filesystem paths never enter public payloads.
- Return every successfully composed WAV as AudioContent with the audio/wav MIME type, regardless of file size.
- Keep structured audio metadata, duration, note sequence, and validation details alongside the multimedia content.
- Use CallToolResult.isError as the authoritative MCP execution status while retaining compose success and validate valid as domain fields.
- Treat invalid compose/API requests and runtime failures as tool errors, while invalid MML discovered by validate remains a successful validation operation.
- Sanitize synthesis, file-write, audio-serialization, and unexpected failure responses so internal paths and exception details are not exposed.
- Add protocol-level coverage for base64 round trips, content block types, error semantics, ResourceLink absence, and path non-disclosure.
- Update existing tests for the separated execution layer and path-free result contract.
- Document AudioContent and isError behavior in the README, MCP schema, and design specification.
- Require the tested FastMCP 3.4.4 API line and exclude the incompatible 4.x major version.
Verification: 487 tests passed; ruff check passed; git diff --check passed; uv lock --check passed; and a manual MCP call returned TextContent plus AudioContent with no wav_path.
Diffstat (limited to 'src/mml_composemusic_mcp/synthesizer.py')
| -rw-r--r-- | src/mml_composemusic_mcp/synthesizer.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/mml_composemusic_mcp/synthesizer.py b/src/mml_composemusic_mcp/synthesizer.py index a289a1e..7085342 100644 --- a/src/mml_composemusic_mcp/synthesizer.py +++ b/src/mml_composemusic_mcp/synthesizer.py @@ -545,14 +545,14 @@ def write_wav(path: Path, wave_data: np.ndarray, sample_rate: int) -> list[Error wav.setsampwidth(2) wav.setframerate(sample_rate) wav.writeframes(pcm.tobytes()) - except Exception as exc: + except Exception: errors.append( ErrorDetail( code=ErrorCode.RUNTIME_WAV_WRITE_FAILED, phase=ErrorPhase.RUNTIME, line=0, column=0, - message=f"WAVファイルの出力に失敗しました: {exc}", + message="WAVファイルの出力に失敗しました。", severity="error", hint="出力先を確認してください。", ) |
