This example MCP server provides basic tools for counting characters and words in a given text. The example shows how MCP servers are built using the Python SDK and demonstrates how MCP server tools are just standard Python functions in an MCP wrapper.
- Claude.ai account (MCP support is available for all account types)
- Claude Desktop app, available for macOS and Windows
- uv:
- macOS via Homebrew:
brew install uv
- Windows via WinGet:
winget install --id=astral-sh.uv -e
- A code editor like Visual Studio Code
uv run-
Start the virtual environment
source .venv/bin/activateNOTE: To stop the virtual environment:
deactivate
-
Run MCP server in dev mode with the MCP Inspector:
mcp dev server.py
-
Open
claude_desktop_config.jsin an editor:File location:
- MacOS / Linux
~/Library/Application/Support/Claude/claude_desktop_config.json - Windows
AppData\Claude\claude_desktop_config.json
- MacOS / Linux
-
Find the full path to
uv:- MacOS / Linux:
which uv
- Windows:
where uv
-
In
claude_desktop_config.js{ "mcpServers": { "text-assist": { "command": "/absolute/path/to/uv", "args": [ "run", "--with", "mcp[cli]", "mcp", "run", "/absolute/path/to/text-assist/server.py" ] } } } -
Reboot Claude Desktop and use a prompt that will trigger your MCP.
In Claude Desktop, you can:
- Count the total number of characters in a text
- Count characters excluding spaces
- Count words in a text
- Count occurrences of specific letters
- Get a full text analysis including:
- Total character count
- Character count without spaces
- Word count
- Space count
- Character frequency distribution