Skip to content

Commit 19f7bbe

Browse files
Format with Prettier
1 parent 0b64349 commit 19f7bbe

36 files changed

+822
-488
lines changed

docs/clients.mdx

Lines changed: 169 additions & 60 deletions
Large diffs are not rendered by default.

docs/docs/concepts/architecture.mdx

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,16 @@ The protocol layer handles message framing, request/response linking, and high-l
9595

9696
Key classes include:
9797

98-
* `Protocol`
99-
* `Client`
100-
* `Server`
98+
- `Protocol`
99+
- `Client`
100+
- `Server`
101101

102102
### Transport layer
103103

104104
The transport layer handles the actual communication between clients and servers. MCP supports multiple transport mechanisms:
105105

106106
1. **Stdio transport**
107+
107108
- Uses standard input/output for communication
108109
- Ideal for local processes
109110

@@ -118,36 +119,39 @@ All transports use [JSON-RPC](https://www.jsonrpc.org/) 2.0 to exchange messages
118119
MCP has these main types of messages:
119120

120121
1. **Requests** expect a response from the other side:
121-
```typescript
122-
interface Request {
123-
method: string;
124-
params?: { ... };
125-
}
126-
```
122+
123+
```typescript
124+
interface Request {
125+
method: string;
126+
params?: { ... };
127+
}
128+
```
127129

128130
2. **Results** are successful responses to requests:
129-
```typescript
130-
interface Result {
131-
[key: string]: unknown;
132-
}
133-
```
131+
132+
```typescript
133+
interface Result {
134+
[key: string]: unknown;
135+
}
136+
```
134137

135138
3. **Errors** indicate that a request failed:
136-
```typescript
137-
interface Error {
138-
code: number;
139-
message: string;
140-
data?: unknown;
141-
}
142-
```
139+
140+
```typescript
141+
interface Error {
142+
code: number;
143+
message: string;
144+
data?: unknown;
145+
}
146+
```
143147

144148
4. **Notifications** are one-way messages that don't expect a response:
145-
```typescript
146-
interface Notification {
147-
method: string;
148-
params?: { ... };
149-
}
150-
```
149+
```typescript
150+
interface Notification {
151+
method: string;
152+
params?: { ... };
153+
}
154+
```
151155

152156
## Connection lifecycle
153157

@@ -180,6 +184,7 @@ After initialization, the following patterns are supported:
180184
### 3. Termination
181185

182186
Either party can terminate the connection:
187+
183188
- Clean shutdown via `close()`
184189
- Transport disconnection
185190
- Error conditions
@@ -195,13 +200,14 @@ enum ErrorCode {
195200
InvalidRequest = -32600,
196201
MethodNotFound = -32601,
197202
InvalidParams = -32602,
198-
InternalError = -32603
203+
InternalError = -32603,
199204
}
200205
```
201206

202207
SDKs and applications can define their own error codes above -32000.
203208

204209
Errors are propagated through:
210+
205211
- Error responses to requests
206212
- Error events on transports
207213
- Protocol-level error handlers
@@ -283,6 +289,7 @@ Here's a basic example of implementing an MCP server:
283289
### Transport selection
284290

285291
1. **Local communication**
292+
286293
- Use stdio transport for local processes
287294
- Efficient for same-machine communication
288295
- Simple process management
@@ -294,12 +301,14 @@ Here's a basic example of implementing an MCP server:
294301
### Message handling
295302

296303
1. **Request processing**
304+
297305
- Validate inputs thoroughly
298306
- Use type-safe schemas
299307
- Handle errors gracefully
300308
- Implement timeouts
301309

302310
2. **Progress reporting**
311+
303312
- Use progress tokens for long operations
304313
- Report progress incrementally
305314
- Include total progress when known
@@ -312,17 +321,20 @@ Here's a basic example of implementing an MCP server:
312321
## Security considerations
313322

314323
1. **Transport security**
324+
315325
- Use TLS for remote connections
316326
- Validate connection origins
317327
- Implement authentication when needed
318328

319329
2. **Message validation**
330+
320331
- Validate all incoming messages
321332
- Sanitize inputs
322333
- Check message size limits
323334
- Verify JSON-RPC format
324335

325336
3. **Resource protection**
337+
326338
- Implement access controls
327339
- Validate resource paths
328340
- Monitor resource usage
@@ -337,12 +349,14 @@ Here's a basic example of implementing an MCP server:
337349
## Debugging and monitoring
338350

339351
1. **Logging**
352+
340353
- Log protocol events
341354
- Track message flow
342355
- Monitor performance
343356
- Record errors
344357

345358
2. **Diagnostics**
359+
346360
- Implement health checks
347361
- Monitor connection state
348362
- Track resource usage

docs/docs/concepts/prompts.mdx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ Prompts enable servers to define reusable prompt templates and workflows that cl
77

88
<Note>
99

10-
Prompts are designed to be **user-controlled**, meaning they are exposed from servers to clients with the intention of the user being able to explicitly select them for use.
10+
Prompts are designed to be **user-controlled**, meaning they are exposed from servers to clients with the intention of the user being able to explicitly select them for use.
1111

1212
</Note>
1313

1414
## Overview
1515

1616
Prompts in MCP are predefined templates that can:
17+
1718
- Accept dynamic arguments
1819
- Include context from resources
1920
- Chain multiple interactions
@@ -45,7 +46,7 @@ Clients can discover available prompts through the `prompts/list` endpoint:
4546
```typescript
4647
// Request
4748
{
48-
method: "prompts/list"
49+
method: "prompts/list";
4950
}
5051

5152
// Response
@@ -58,19 +59,19 @@ Clients can discover available prompts through the `prompts/list` endpoint:
5859
{
5960
name: "language",
6061
description: "Programming language",
61-
required: true
62-
}
63-
]
64-
}
65-
]
62+
required: true,
63+
},
64+
],
65+
},
66+
];
6667
}
6768
```
6869

6970
## Using prompts
7071

7172
To use a prompt, clients make a `prompts/get` request:
7273

73-
```typescript
74+
````typescript
7475
// Request
7576
{
7677
method: "prompts/get",
@@ -95,7 +96,7 @@ To use a prompt, clients make a `prompts/get` request:
9596
}
9697
]
9798
}
98-
```
99+
````
99100

100101
## Dynamic prompts
101102

@@ -171,25 +172,25 @@ const debugWorkflow = {
171172
role: "user",
172173
content: {
173174
type: "text",
174-
text: `Here's an error I'm seeing: ${error}`
175-
}
175+
text: `Here's an error I'm seeing: ${error}`,
176+
},
176177
},
177178
{
178179
role: "assistant",
179180
content: {
180181
type: "text",
181-
text: "I'll help analyze this error. What have you tried so far?"
182-
}
182+
text: "I'll help analyze this error. What have you tried so far?",
183+
},
183184
},
184185
{
185186
role: "user",
186187
content: {
187188
type: "text",
188-
text: "I've tried restarting the service, but the error persists."
189-
}
190-
}
189+
text: "I've tried restarting the service, but the error persists.",
190+
},
191+
},
191192
];
192-
}
193+
},
193194
};
194195
```
195196

docs/docs/concepts/resources.mdx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ Resources are a core primitive in the Model Context Protocol (MCP) that allow se
77

88
<Note>
99

10-
Resources are designed to be **application-controlled**, meaning that the client application can decide how and when they should be used.
11-
Different MCP clients may handle resources differently. For example:
12-
- Claude Desktop currently requires users to explicitly select resources before they can be used
13-
- Other clients might automatically select resources based on heuristics
14-
- Some implementations may even allow the AI model itself to determine which resources to use
10+
Resources are designed to be **application-controlled**, meaning that the client application can decide how and when they should be used.
11+
Different MCP clients may handle resources differently. For example:
1512

16-
Server authors should be prepared to handle any of these interaction patterns when implementing resource support. In order to expose data to models automatically, server authors should use a **model-controlled** primitive such as [Tools](./tools).
13+
- Claude Desktop currently requires users to explicitly select resources before they can be used
14+
- Other clients might automatically select resources based on heuristics
15+
- Some implementations may even allow the AI model itself to determine which resources to use
16+
17+
Server authors should be prepared to handle any of these interaction patterns when implementing resource support. In order to expose data to models automatically, server authors should use a **model-controlled** primitive such as [Tools](./tools).
1718

1819
</Note>
1920

@@ -40,6 +41,7 @@ Resources are identified using URIs that follow this format:
4041
```
4142

4243
For example:
44+
4345
- `file:///home/user/documents/report.pdf`
4446
- `postgres://database/customers/schema`
4547
- `screen://localhost/display1`
@@ -53,6 +55,7 @@ Resources can contain two types of content:
5355
### Text resources
5456

5557
Text resources contain UTF-8 encoded text data. These are suitable for:
58+
5659
- Source code
5760
- Configuration files
5861
- Log files
@@ -62,6 +65,7 @@ Text resources contain UTF-8 encoded text data. These are suitable for:
6265
### Binary resources
6366

6467
Binary resources contain raw binary data encoded in base64. These are suitable for:
68+
6569
- Images
6670
- PDFs
6771
- Audio files
@@ -122,7 +126,7 @@ The server responds with a list of resource contents:
122126

123127
<Tip>
124128

125-
Servers may return multiple resources in response to one `resources/read` request. This could be used, for example, to return a list of files inside a directory when the directory is read.
129+
Servers may return multiple resources in response to one `resources/read` request. This could be used, for example, to return a list of files inside a directory when the directory is read.
126130

127131
</Tip>
128132

docs/docs/concepts/roots.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ Here's how a typical MCP client might expose roots:
7676
}
7777
```
7878

79-
This configuration suggests the server focus on both a local repository and an API endpoint while keeping them logically separated.
79+
This configuration suggests the server focus on both a local repository and an API endpoint while keeping them logically separated.

docs/docs/concepts/sampling.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Sampling is a powerful MCP feature that allows servers to request LLM completion
77

88
<Info>
99

10-
This feature of MCP is not yet supported in the Claude Desktop client.
10+
This feature of MCP is not yet supported in the Claude Desktop client.
1111

1212
</Info>
1313

@@ -77,6 +77,7 @@ The `messages` array contains the conversation history to send to the LLM. Each
7777
The `modelPreferences` object allows servers to specify their model selection preferences:
7878

7979
- `hints`: Array of model name suggestions that clients can use to select an appropriate model:
80+
8081
- `name`: String that can match full or partial model names (e.g. "claude-3", "sonnet")
8182
- Clients may map hints to equivalent models from different providers
8283
- Multiple hints are evaluated in preference order
@@ -132,6 +133,7 @@ The client returns a completion result:
132133
## Example request
133134

134135
Here's an example of requesting sampling from a client:
136+
135137
```json
136138
{
137139
"method": "sampling/createMessage",

docs/docs/concepts/tools.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Tools are a powerful primitive in the Model Context Protocol (MCP) that enable s
77

88
<Note>
99

10-
Tools are designed to be **model-controlled**, meaning that tools are exposed from servers to clients with the intention of the AI model being able to automatically invoke them (with a human in the loop to grant approval).
10+
Tools are designed to be **model-controlled**, meaning that tools are exposed from servers to clients with the intention of the AI model being able to automatically invoke them (with a human in the loop to grant approval).
1111

1212
</Note>
1313

@@ -336,13 +336,13 @@ Tool annotations serve several key purposes:
336336

337337
The MCP specification defines the following annotations for tools:
338338

339-
| Annotation | Type | Default | Description |
340-
|------------|------|---------|-------------|
341-
| `title` | string | - | A human-readable title for the tool, useful for UI display |
342-
| `readOnlyHint` | boolean | false | If true, indicates the tool does not modify its environment |
343-
| `destructiveHint` | boolean | true | If true, the tool may perform destructive updates (only meaningful when `readOnlyHint` is false) |
344-
| `idempotentHint` | boolean | false | If true, calling the tool repeatedly with the same arguments has no additional effect (only meaningful when `readOnlyHint` is false) |
345-
| `openWorldHint` | boolean | true | If true, the tool may interact with an "open world" of external entities |
339+
| Annotation | Type | Default | Description |
340+
| ----------------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ |
341+
| `title` | string | - | A human-readable title for the tool, useful for UI display |
342+
| `readOnlyHint` | boolean | false | If true, indicates the tool does not modify its environment |
343+
| `destructiveHint` | boolean | true | If true, the tool may perform destructive updates (only meaningful when `readOnlyHint` is false) |
344+
| `idempotentHint` | boolean | false | If true, calling the tool repeatedly with the same arguments has no additional effect (only meaningful when `readOnlyHint` is false) |
345+
| `openWorldHint` | boolean | true | If true, the tool may interact with an "open world" of external entities |
346346

347347
### Example usage
348348

0 commit comments

Comments
 (0)