count_letters
Count occurrences of a specific letter in a given word using this utility. Input the word and letter to get precise results.
Instructions
Count the number of times a letter appears in a word
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| letter | Yes | The letter to count | |
| word | Yes | The word to count letters in |
Implementation Reference
- server.py:16-20 (handler)The handler function for the count_letters MCP tool. It defines the input parameters with schema and delegates execution to the core implementation.def count_letters( word: Annotated[str, Field(description="The word to count letters in")], letter: Annotated[str, Field(description="The letter to count")], ) -> int: return count_letters_impl(word, letter)
- server.py:12-15 (registration)Registration of the count_letters tool using FastMCP's @mcp.tool decorator, specifying name and description.@mcp.tool( name="count_letters", description="Count the number of times a letter appears in a word", )
- tools/count_letters_tool.py:6-11 (helper)Core helper function implementing the letter counting logic: converts to lowercase and uses string count method.def count_letters_impl( word: Annotated[str, Field(description="The word to count letters in")], letter: Annotated[str, Field(description="The letter to count")], ) -> int: """Count the number of times a letter appears in a word.""" return word.lower().count(letter.lower())
- server.py:17-18 (schema)Pydantic-based input schema for the tool parameters: word (str) and letter (str).word: Annotated[str, Field(description="The word to count letters in")], letter: Annotated[str, Field(description="The letter to count")],