Skip to content

Commit c6d2eb2

Browse files
authored
chore: Improve annotation (#17)
1 parent 612175d commit c6d2eb2

File tree

8 files changed

+199
-267
lines changed

8 files changed

+199
-267
lines changed

mcp_toolbox/audio/tools.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import datetime
44
import os
55
from pathlib import Path
6-
from typing import Any
6+
from typing import Annotated, Any
77

88
import whisper
99
from loguru import logger
10+
from pydantic import Field
1011

1112
from mcp_toolbox.app import mcp
1213

@@ -77,10 +78,10 @@ def load_audio(audio_path, model_name="base"):
7778
return _audio
7879

7980

80-
@mcp.tool(
81-
description="Get the length of an audio file in seconds. Args: audio_path (required, The path to the audio file)"
82-
)
83-
async def get_audio_length(audio_path: str) -> dict[str, Any]:
81+
@mcp.tool(description="Get the length of an audio file in seconds.")
82+
async def get_audio_length(
83+
audio_path: Annotated[str, Field(description="The path to the audio file")],
84+
) -> dict[str, Any]:
8485
"""Get the length of an audio file in seconds.
8586
8687
Args:
@@ -112,11 +113,14 @@ async def get_audio_length(audio_path: str) -> dict[str, Any]:
112113
}
113114

114115

115-
@mcp.tool(
116-
description="Get transcribed text from a specific time range in an audio file. Args: audio_path (required, The path to the audio file), start_time (required, Start time in seconds), end_time (required, End time in seconds), model_name (optional, Whisper model name: tiny, base, small, medium, large)"
117-
)
116+
@mcp.tool(description="Get transcribed text from a specific time range in an audio file.")
118117
async def get_audio_text(
119-
audio_path: str, start_time: float, end_time: float, model_name: str = "base"
118+
audio_path: Annotated[str, Field(description="The path to the audio file")],
119+
start_time: Annotated[float, Field(description="Start time in seconds")],
120+
end_time: Annotated[float, Field(description="End time in seconds")],
121+
model_name: Annotated[
122+
str, Field(default="base", description="Whisper model name: tiny, base, small, medium, large")
123+
] = "base",
120124
) -> dict[str, Any]:
121125
"""Extract and transcribe text from a specific time range in an audio file.
122126

mcp_toolbox/command_line/tools.py

+8-17
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,20 @@
44
import contextlib
55
import os
66
from pathlib import Path
7-
from typing import Any
7+
from typing import Annotated, Any
8+
9+
from pydantic import Field
810

911
from mcp_toolbox.app import mcp
1012

1113

12-
@mcp.tool(
13-
description="Execute a command line instruction. Args: command (required, The command to execute as a list of strings), timeout_seconds (optional, Maximum execution time in seconds), working_dir (optional, Directory to execute the command in)"
14-
)
14+
@mcp.tool(description="Execute a command line instruction.")
1515
async def execute_command(
16-
command: list[str],
17-
timeout_seconds: int = 30,
18-
working_dir: str | None = None,
16+
command: Annotated[list[str], Field(description="The command to execute as a list of strings")],
17+
timeout_seconds: Annotated[int, Field(default=30, description="Maximum execution time in seconds")] = 30,
18+
working_dir: Annotated[str | None, Field(default=None, description="Directory to execute the command in")] = None,
1919
) -> dict[str, Any]:
20-
"""Execute a command line instruction.
21-
22-
Args:
23-
command: The command to execute as a list of strings
24-
timeout_seconds: Optional. Maximum execution time in seconds (default: 30)
25-
working_dir: Optional. Directory to execute the command in
26-
27-
Returns:
28-
Dictionary containing stdout, stderr, and return code
29-
"""
20+
"""Execute a command line instruction."""
3021
if not command:
3122
return {
3223
"error": "Command cannot be empty",

0 commit comments

Comments
 (0)