Skip to content

Commit 93cf83e

Browse files
committed
chore: add markdownlint configuration and pre-commit hook for markdown files
1 parent 7942184 commit 93cf83e

File tree

12 files changed

+117
-61
lines changed

12 files changed

+117
-61
lines changed

.markdownlint.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
default: true
2+
3+
# MD004 ul-style - Unordered list style
4+
MD004: false
5+
6+
# MD007 ul-indent - Unordered list indentation
7+
MD007:
8+
indent: 4
9+
10+
# MD013 line-length - Line length
11+
MD013: false
12+
13+
# MD029 ol-prefix - Ordered list item prefix
14+
MD029: false
15+
16+
# MD033 no-inline-html Inline HTML
17+
MD033: false
18+
19+
# MD041 first-line-heading/first-line-h1
20+
MD041: false
21+
22+
# MD059 descriptive-link-text
23+
MD059: false

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ repos:
77
- id: prettier
88
types_or: [yaml, json5]
99

10+
- repo: https://github.com/DavidAnson/markdownlint-cli2
11+
rev: v0.18.1
12+
hooks:
13+
- id: markdownlint-cli2
14+
args: ["--fix"]
15+
types: [markdown]
16+
1017
- repo: local
1118
hooks:
1219
- id: ruff-format

CLAUDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@ This document contains critical information about working with this codebase. Fo
2626
- Bug fixes require regression tests
2727

2828
- For commits fixing bugs or adding features based on user reports add:
29+
2930
```bash
3031
git commit --trailer "Reported-by:<name>"
3132
```
33+
3234
Where `<name>` is the name of the user.
3335

3436
- For commits related to a Github issue, add
37+
3538
```bash
3639
git commit --trailer "Github-Issue:#<number>"
3740
```
41+
3842
- NEVER ever mention a `co-authored-by` or similar aspects. In particular, never
3943
mention the tool used to create the commit message or PR.
4044

CODE_OF_CONDUCT.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ representative at an online or offline event.
6060

6161
Instances of abusive, harassing, or otherwise unacceptable behavior may be
6262
reported to the community leaders responsible for enforcement at
63-
63+
6464
All complaints will be reviewed and investigated promptly and fairly.
6565

6666
All community leaders are obligated to respect the privacy and security of the
@@ -116,13 +116,13 @@ the community.
116116

117117
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118118
version 2.0, available at
119-
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
119+
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
120120

121121
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122122
enforcement ladder](https://github.com/mozilla/diversity).
123123

124124
[homepage]: https://www.contributor-covenant.org
125125

126126
For answers to common questions about this code of conduct, see the FAQ at
127-
https://www.contributor-covenant.org/faq. Translations are available at
128-
https://www.contributor-covenant.org/translations.
127+
<https://www.contributor-covenant.org/faq>. Translations are available at
128+
<https://www.contributor-covenant.org/translations>.

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Thank you for your interest in contributing to the MCP Python SDK! This document
99
3. Fork the repository
1010
4. Clone your fork: `git clone https://github.com/YOUR-USERNAME/python-sdk.git`
1111
5. Install dependencies:
12+
1213
```bash
1314
uv sync --frozen --all-extras --dev
1415
```
@@ -25,16 +26,19 @@ uv sync --frozen --all-extras --dev
2526
3. Make your changes
2627

2728
4. Ensure tests pass:
28-
```bash
29+
30+
```bash
2931
uv run pytest
3032
```
3133

3234
5. Run type checking:
35+
3336
```bash
3437
uv run pyright
3538
```
3639

3740
6. Run linting:
41+
3842
```bash
3943
uv run ruff check .
4044
uv run ruff format .

README.md

Lines changed: 54 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,39 @@
1717
## Table of Contents
1818

1919
- [MCP Python SDK](#mcp-python-sdk)
20-
- [Overview](#overview)
21-
- [Installation](#installation)
22-
- [Adding MCP to your python project](#adding-mcp-to-your-python-project)
23-
- [Running the standalone MCP development tools](#running-the-standalone-mcp-development-tools)
24-
- [Quickstart](#quickstart)
25-
- [What is MCP?](#what-is-mcp)
26-
- [Core Concepts](#core-concepts)
27-
- [Server](#server)
28-
- [Resources](#resources)
29-
- [Tools](#tools)
30-
- [Structured Output](#structured-output)
31-
- [Prompts](#prompts)
32-
- [Images](#images)
33-
- [Context](#context)
34-
- [Completions](#completions)
35-
- [Elicitation](#elicitation)
36-
- [Authentication](#authentication)
37-
- [Running Your Server](#running-your-server)
38-
- [Development Mode](#development-mode)
39-
- [Claude Desktop Integration](#claude-desktop-integration)
40-
- [Direct Execution](#direct-execution)
41-
- [Mounting to an Existing ASGI Server](#mounting-to-an-existing-asgi-server)
42-
- [Examples](#examples)
43-
- [Echo Server](#echo-server)
44-
- [SQLite Explorer](#sqlite-explorer)
45-
- [Advanced Usage](#advanced-usage)
46-
- [Low-Level Server](#low-level-server)
47-
- [Writing MCP Clients](#writing-mcp-clients)
48-
- [MCP Primitives](#mcp-primitives)
49-
- [Server Capabilities](#server-capabilities)
50-
- [Documentation](#documentation)
51-
- [Contributing](#contributing)
52-
- [License](#license)
20+
- [Overview](#overview)
21+
- [Installation](#installation)
22+
- [Adding MCP to your python project](#adding-mcp-to-your-python-project)
23+
- [Running the standalone MCP development tools](#running-the-standalone-mcp-development-tools)
24+
- [Quickstart](#quickstart)
25+
- [What is MCP?](#what-is-mcp)
26+
- [Core Concepts](#core-concepts)
27+
- [Server](#server)
28+
- [Resources](#resources)
29+
- [Tools](#tools)
30+
- [Structured Output](#structured-output)
31+
- [Prompts](#prompts)
32+
- [Images](#images)
33+
- [Context](#context)
34+
- [Completions](#completions)
35+
- [Elicitation](#elicitation)
36+
- [Authentication](#authentication)
37+
- [Running Your Server](#running-your-server)
38+
- [Development Mode](#development-mode)
39+
- [Claude Desktop Integration](#claude-desktop-integration)
40+
- [Direct Execution](#direct-execution)
41+
- [Mounting to an Existing ASGI Server](#mounting-to-an-existing-asgi-server)
42+
- [Examples](#examples)
43+
- [Echo Server](#echo-server)
44+
- [SQLite Explorer](#sqlite-explorer)
45+
- [Advanced Usage](#advanced-usage)
46+
- [Low-Level Server](#low-level-server)
47+
- [Writing MCP Clients](#writing-mcp-clients)
48+
- [MCP Primitives](#mcp-primitives)
49+
- [Server Capabilities](#server-capabilities)
50+
- [Documentation](#documentation)
51+
- [Contributing](#contributing)
52+
- [License](#license)
5353

5454
[pypi-badge]: https://img.shields.io/pypi/v/mcp.svg
5555
[pypi-url]: https://pypi.org/project/mcp/
@@ -93,6 +93,7 @@ If you haven't created a uv-managed project yet, create one:
9393
```
9494

9595
Alternatively, for projects using pip for dependencies:
96+
9697
```bash
9798
pip install "mcp[cli]"
9899
```
@@ -132,11 +133,13 @@ def get_greeting(name: str) -> str:
132133
```
133134

134135
You can install this server in [Claude Desktop](https://claude.ai/download) and interact with it right away by running:
136+
135137
```bash
136138
mcp install server.py
137139
```
138140

139141
Alternatively, you can test it with the MCP Inspector:
142+
140143
```bash
141144
mcp dev server.py
142145
```
@@ -253,9 +256,10 @@ async def fetch_weather(city: str) -> str:
253256
#### Structured Output
254257

255258
Tools will return structured results by default, if their return type
256-
annotation is compatible. Otherwise, they will return unstructured results.
259+
annotation is compatible. Otherwise, they will return unstructured results.
257260

258261
Structured output supports these return types:
262+
259263
- Pydantic models (BaseModel subclasses)
260264
- TypedDicts
261265
- Dataclasses and other classes with type hints
@@ -267,17 +271,17 @@ Classes without type hints cannot be serialized for structured output. Only
267271
classes with properly annotated attributes will be converted to Pydantic models
268272
for schema generation and validation.
269273

270-
Structured results are automatically validated against the output schema
271-
generated from the annotation. This ensures the tool returns well-typed,
274+
Structured results are automatically validated against the output schema
275+
generated from the annotation. This ensures the tool returns well-typed,
272276
validated data that clients can easily process.
273277

274278
**Note:** For backward compatibility, unstructured results are also
275-
returned. Unstructured results are provided for backward compatibility
279+
returned. Unstructured results are provided for backward compatibility
276280
with previous versions of the MCP specification, and are quirks-compatible
277281
with previous versions of FastMCP in the current version of the SDK.
278282

279-
**Note:** In cases where a tool function's return type annotation
280-
causes the tool to be classified as structured _and this is undesirable_,
283+
**Note:** In cases where a tool function's return type annotation
284+
causes the tool to be classified as structured _and this is undesirable_,
281285
the classification can be suppressed by passing `structured_output=False`
282286
to the `@tool` decorator.
283287

@@ -440,6 +444,7 @@ async def long_task(files: list[str], ctx: Context) -> str:
440444
MCP supports providing completion suggestions for prompt arguments and resource template parameters. With the context parameter, servers can provide completions based on previously resolved values:
441445

442446
Client usage:
447+
443448
```python
444449
from mcp.client.session import ClientSession
445450
from mcp.types import ResourceTemplateReference
@@ -465,6 +470,7 @@ async def use_completion(session: ClientSession):
465470
```
466471

467472
Server implementation:
473+
468474
```python
469475
from mcp.server import Server
470476
from mcp.types import (
@@ -496,6 +502,7 @@ async def handle_completion(
496502
return Completion(values=filtered)
497503
return None
498504
```
505+
499506
### Elicitation
500507

501508
Request additional information from users during tool execution:
@@ -537,6 +544,7 @@ async def book_table(date: str, party_size: int, ctx: Context) -> str:
537544
```
538545

539546
The `elicit()` method returns an `ElicitationResult` with:
547+
540548
- `action`: "accept", "decline", or "cancel"
541549
- `data`: The validated response (only when accepted)
542550
- `validation_error`: Any validation error message
@@ -576,6 +584,7 @@ mcp = FastMCP(
576584
For a complete example with separate Authorization Server and Resource Server implementations, see [`examples/servers/simple-auth/`](examples/servers/simple-auth/).
577585

578586
**Architecture:**
587+
579588
- **Authorization Server (AS)**: Handles OAuth flows, user authentication, and token issuance
580589
- **Resource Server (RS)**: Your MCP server that validates tokens and serves protected resources
581590
- **Client**: Discovers AS through RFC 9728, obtains tokens, and uses them with the MCP server
@@ -627,6 +636,7 @@ if __name__ == "__main__":
627636
```
628637

629638
Run it with:
639+
630640
```bash
631641
python server.py
632642
# or
@@ -704,10 +714,12 @@ app.mount("/math", math.mcp.streamable_http_app())
704714
```
705715

706716
For low level server with Streamable HTTP implementations, see:
717+
707718
- Stateful server: [`examples/servers/simple-streamablehttp/`](examples/servers/simple-streamablehttp/)
708719
- Stateless server: [`examples/servers/simple-streamablehttp-stateless/`](examples/servers/simple-streamablehttp-stateless/)
709720

710721
The streamable HTTP transport supports:
722+
711723
- Stateful and stateless operation modes
712724
- Resumability with event stores
713725
- JSON or SSE response formats
@@ -880,6 +892,7 @@ async def query_db(name: str, arguments: dict) -> list:
880892
```
881893

882894
The lifespan API provides:
895+
883896
- A way to initialize resources when the server starts and clean them up when it stops
884897
- Access to initialized resources through the request context in handlers
885898
- Type-safe context passing between lifespan and request handlers
@@ -1006,6 +1019,7 @@ async def call_tool(name: str, arguments: dict[str, Any]) -> dict[str, Any]:
10061019
```
10071020

10081021
Tools can return data in three ways:
1022+
10091023
1. **Content only**: Return a list of content blocks (default behavior before spec revision 2025-06-18)
10101024
2. **Structured data only**: Return a dictionary that will be serialized to JSON (Introduced in spec revision 2025-06-18)
10111025
3. **Both**: Return a tuple of (content, structured_data) preferred option to use for backwards compatibility
@@ -1131,6 +1145,7 @@ async def display_resources(session: ClientSession):
11311145
```
11321146

11331147
The `get_display_name()` function implements the proper precedence rules for displaying names:
1148+
11341149
- For tools: `title` > `annotations.title` > `name`
11351150
- For other objects: `title` > `name`
11361151

@@ -1189,7 +1204,6 @@ async def main():
11891204

11901205
For a complete working example, see [`examples/clients/simple-auth-client/`](examples/clients/simple-auth-client/).
11911206

1192-
11931207
### MCP Primitives
11941208

11951209
The MCP protocol defines three core primitives that servers can implement:

SECURITY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Security Policy
2+
23
Thank you for helping us keep the SDKs and systems they interact with secure.
34

45
## Reporting Security Issues

examples/clients/simple-auth-client/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The client will open your browser for authentication. After completing OAuth, yo
4747

4848
## Example
4949

50-
```
50+
```markdown
5151
🔐 Simple MCP Auth Client
5252
Connecting to: http://localhost:3001
5353

examples/clients/simple-chatbot/README.MD

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ This example demonstrates how to integrate the Model Context Protocol (MCP) into
2525
```plaintext
2626
LLM_API_KEY=your_api_key_here
2727
```
28+
2829
**Note:** The current implementation is configured to use the Groq API endpoint (`https://api.groq.com/openai/v1/chat/completions`) with the `llama-3.2-90b-vision-preview` model. If you plan to use a different LLM provider, you'll need to modify the `LLMClient` class in `main.py` to use the appropriate endpoint URL and model parameters.
2930

3031
3. **Configure servers:**
3132

32-
The `servers_config.json` follows the same structure as Claude Desktop, allowing for easy integration of multiple servers.
33+
The `servers_config.json` follows the same structure as Claude Desktop, allowing for easy integration of multiple servers.
3334
Here's an example:
3435

3536
```json
@@ -46,9 +47,11 @@ This example demonstrates how to integrate the Model Context Protocol (MCP) into
4647
}
4748
}
4849
```
50+
4951
Environment variables are supported as well. Pass them as you would with the Claude Desktop App.
5052

5153
Example:
54+
5255
```json
5356
{
5457
"mcpServers": {
@@ -72,7 +75,7 @@ This example demonstrates how to integrate the Model Context Protocol (MCP) into
7275
```
7376

7477
2. **Interact with the assistant:**
75-
78+
7679
The assistant will automatically detect available tools and can respond to queries based on the tools provided by the configured servers.
7780

7881
3. **Exit the session:**
@@ -86,6 +89,7 @@ This example demonstrates how to integrate the Model Context Protocol (MCP) into
8689
- **Server Integration**: Supports any MCP-compatible server, tested with various server implementations including Uvicorn and Node.js.
8790

8891
### Class Structure
92+
8993
- **Configuration**: Manages environment variables and server configurations
9094
- **Server**: Handles MCP server initialization, tool discovery, and execution
9195
- **Tool**: Represents individual tools with their properties and formatting
@@ -107,5 +111,3 @@ This example demonstrates how to integrate the Model Context Protocol (MCP) into
107111
- If it's a direct response → return to user
108112
- Tool results are sent back to LLM for interpretation
109113
- Final response is presented to user
110-
111-

0 commit comments

Comments
 (0)