# Claude Code MCP: A Practical Tutorial

> Source: <https://promptcube3.com/en/threads/3333/>
> Published: 2026-07-25 19:01:33+00:00

# Claude Code MCP: A Practical Tutorial

[Claude](/en/tags/claude/)Code. I managed to get a custom server up and running in about 10 minutes using Python.

## Project Setup

I used `uv`

for this because it's significantly faster than standard pip for managing environments.

```
uv init word-count-mcp
cd word-count-mcp
uv add "mcp[cli]"
```

## Implementation

The official SDK makes the deployment straightforward. You just need a single file to define your logic. The key is using type hints and docstrings; the SDK uses these to generate the schema that tells the LLM exactly how to use the tool.

Create `server.py`

:

``` python
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("word-count")

@mcp.tool()
def word_count(text: str) -> dict:
 """Count the words, characters, and lines in a block of text.

 Args:
 text: The text to analyze.
 """
 words = text.split()
 return {
 "words": len(words),
 "characters": len(text),
 "characters_no_spaces": len("".join(text.split())),
 "lines": len(text.splitlines()),
 }

if __name__ == "__main__":
 mcp.run(transport="stdio")
```

## Connecting to Claude Code

Since this is a stdio-based server, it stays idle until a client connects via stdin/stdout. To link this to your AI workflow, register it directly within the Claude Code CLI:

```
claude mcp add word-count -- uv run --directory "$(pwd)" server.py
```

The command following the `--`

tells Claude exactly how to execute the server. Once registered, the model can autonomously decide when to call the `word_count`

tool based on the user's prompt. This is a highly efficient way to build a custom LLM agent without the overhead of managing complex API endpoints.

[Next Insight Compiler: Stopping Generic AI Advice →](/en/threads/3323/)
