grammar
This commit is contained in:
parent
6cac5a1cde
commit
ba7d5b866d
2 changed files with 79 additions and 1432 deletions
|
|
@ -1,9 +1,9 @@
|
|||
---
|
||||
title: "TypeScript Class Reference"
|
||||
title: "TypeScript class reference"
|
||||
description: "Complete TypeScript SDK class documentation"
|
||||
---
|
||||
|
||||
## Client Classes
|
||||
## Client classes
|
||||
|
||||
### Client
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ getServerVersion(): Implementation | undefined
|
|||
```
|
||||
Returns the server's version information after connection.
|
||||
|
||||
### Transport Classes
|
||||
### Transport classes
|
||||
|
||||
#### StdioClientTransport
|
||||
```typescript
|
||||
|
|
@ -103,7 +103,7 @@ import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/webso
|
|||
constructor(url: URL)
|
||||
```
|
||||
|
||||
## Server Classes
|
||||
## Server classes
|
||||
|
||||
### Server
|
||||
|
||||
|
|
@ -173,7 +173,7 @@ getClientVersion(): Implementation | undefined
|
|||
```
|
||||
Returns the client's version information after connection.
|
||||
|
||||
### Transport Classes
|
||||
### Transport classes
|
||||
|
||||
#### StdioServerTransport
|
||||
```typescript
|
||||
|
|
@ -197,7 +197,7 @@ constructor(endpoint: string, res: ServerResponse)
|
|||
|
||||
## Examples
|
||||
|
||||
### Client Implementation
|
||||
### Client implementation
|
||||
|
||||
```typescript
|
||||
import { Client } from "@modelcontextprotocol/sdk/client";
|
||||
|
|
@ -269,7 +269,7 @@ async function main() {
|
|||
}
|
||||
```
|
||||
|
||||
### Server Implementation
|
||||
### Server implementation
|
||||
|
||||
```typescript
|
||||
import { Server } from "@modelcontextprotocol/sdk/server";
|
||||
|
|
@ -363,7 +363,7 @@ async function main() {
|
|||
}
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
## Best practices
|
||||
|
||||
1. **Error Handling**
|
||||
```typescript
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
---
|
||||
title: "TypeScript Type Definitions"
|
||||
title: "TypeScript type definitions"
|
||||
description: "TypeScript type system documentation"
|
||||
---
|
||||
|
||||
## Core Protocol Types
|
||||
## Core protocol types
|
||||
|
||||
### JSON-RPC Types
|
||||
### JSON-RPC types
|
||||
|
||||
```typescript
|
||||
export const JSONRPC_VERSION = "2.0";
|
||||
|
|
@ -53,7 +53,7 @@ export type JSONRPCMessage =
|
|||
| JSONRPCError;
|
||||
```
|
||||
|
||||
### Message Content Types
|
||||
### Message content types
|
||||
|
||||
```typescript
|
||||
/** Text provided to or from an LLM */
|
||||
|
|
@ -84,7 +84,7 @@ export interface Progress {
|
|||
export type ProgressCallback = (progress: Progress) => void;
|
||||
```
|
||||
|
||||
### Resource Types
|
||||
### Resource types
|
||||
|
||||
```typescript
|
||||
/** The contents of a specific resource */
|
||||
|
|
@ -120,7 +120,7 @@ export interface ResourceTemplate {
|
|||
}
|
||||
```
|
||||
|
||||
### Tool Types
|
||||
### Tool types
|
||||
|
||||
```typescript
|
||||
/** Definition for a tool the client can call */
|
||||
|
|
@ -134,7 +134,7 @@ export interface Tool {
|
|||
}
|
||||
```
|
||||
|
||||
### Prompt Types
|
||||
### Prompt types
|
||||
|
||||
```typescript
|
||||
/** Describes an argument that a prompt can accept */
|
||||
|
|
@ -152,9 +152,9 @@ export interface Prompt {
|
|||
}
|
||||
```
|
||||
|
||||
## Request/Response Types
|
||||
## Request/response types
|
||||
|
||||
### Resource Requests
|
||||
### Resource requests
|
||||
|
||||
```typescript
|
||||
export interface ListResourcesRequest {
|
||||
|
|
@ -195,7 +195,7 @@ export interface UnsubscribeRequest {
|
|||
}
|
||||
```
|
||||
|
||||
### Tool Requests
|
||||
### Tool requests
|
||||
|
||||
```typescript
|
||||
export interface ListToolsRequest {
|
||||
|
|
@ -226,7 +226,7 @@ export interface CallToolResult {
|
|||
}
|
||||
```
|
||||
|
||||
### Prompt Requests
|
||||
### Prompt requests
|
||||
|
||||
```typescript
|
||||
export interface ListPromptsRequest {
|
||||
|
|
@ -255,9 +255,9 @@ export interface GetPromptResult {
|
|||
}
|
||||
```
|
||||
|
||||
## Protocol Types
|
||||
## Protocol types
|
||||
|
||||
### Implementation Info
|
||||
### Implementation info
|
||||
|
||||
```typescript
|
||||
export interface Implementation {
|
||||
|
|
@ -266,7 +266,7 @@ export interface Implementation {
|
|||
}
|
||||
```
|
||||
|
||||
### Capability Types
|
||||
### Capability types
|
||||
|
||||
```typescript
|
||||
export interface ResourceCapabilities {
|
||||
|
|
@ -296,7 +296,7 @@ export interface ClientCapabilities {
|
|||
}
|
||||
```
|
||||
|
||||
### Notification Types
|
||||
### Notification types
|
||||
|
||||
```typescript
|
||||
export interface ResourceUpdatedNotification {
|
||||
|
|
@ -328,7 +328,7 @@ export type ServerNotification =
|
|||
| LogMessageNotification;
|
||||
```
|
||||
|
||||
## Error Types
|
||||
## Error types
|
||||
|
||||
```typescript
|
||||
export enum ErrorCode {
|
||||
|
|
@ -354,7 +354,7 @@ export class McpError extends Error {
|
|||
}
|
||||
```
|
||||
|
||||
## Transport Types
|
||||
## Transport types
|
||||
|
||||
```typescript
|
||||
export interface Transport {
|
||||
|
|
@ -373,9 +373,9 @@ export interface StdioServerParameters {
|
|||
}
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
## Usage examples
|
||||
|
||||
### Type Guards
|
||||
### Type guards
|
||||
|
||||
```typescript
|
||||
function isTextContent(content:
|
||||
|
|
@ -391,7 +391,7 @@ function isResourceUpdatedNotification(
|
|||
}
|
||||
```
|
||||
|
||||
### Type Assertions
|
||||
### Type assertions
|
||||
|
||||
```typescript
|
||||
function assertResource(data: unknown): asserts data is Resource {
|
||||
|
|
@ -409,7 +409,7 @@ function assertResource(data: unknown): asserts data is Resource {
|
|||
}
|
||||
```
|
||||
|
||||
### Using Generics
|
||||
### Using generics
|
||||
|
||||
```typescript
|
||||
async function handleResourceContent<T extends ResourceContents>(
|
||||
|
|
@ -425,7 +425,7 @@ async function handleResourceContent<T extends ResourceContents>(
|
|||
}
|
||||
```
|
||||
|
||||
### Working with Union Types
|
||||
### Working with union types
|
||||
|
||||
```typescript
|
||||
function processMessage(message: SamplingMessage): string {
|
||||
|
|
@ -442,7 +442,7 @@ function processMessage(message: SamplingMessage): string {
|
|||
}
|
||||
```
|
||||
|
||||
## Type Utilities
|
||||
## Type utilities
|
||||
|
||||
```typescript
|
||||
/** Helper type to extract request params from method name */
|
||||
|
|
|
|||
Loading…
Reference in a new issue