# MCP Toolkit Examples

This directory contains examples demonstrating how to use the MCP Toolkit in various scenarios.

## Basic Examples

The `basic` directory contains simple examples that demonstrate the core functionality:

- **[simple-client.ts](./basic/simple-client.ts)**: A basic client that connects to an MCP server, discovers tools, executes a tool call, and reads resources.

## Advanced Examples

The `advanced` directory contains more complex examples that demonstrate advanced features:

- **[multi-server.ts](./advanced/multi-server.ts)**: Shows how to work with multiple servers, execute parallel tool calls, and handle advanced error recovery.

## Running the Examples

To run the examples, you'll need to:

1. Build the toolkit:
   ```bash
   npm install
   npm run build
   ```

2. Run an example using tsx (TypeScript execution):
   ```bash
   npx tsx examples/basic/simple-client.ts
   ```

## Key Features Demonstrated

1. **Client Creation and Configuration**
   - Creating a client with custom settings
   - Configuring capabilities and timeouts

2. **Server Connection**
   - Connecting to local servers using stdio transport
   - Connecting to remote servers using SSE transport
   - Managing multiple server connections

3. **Tool Discovery and Execution**
   - Listing available tools
   - Executing tool calls with parameters
   - Handling tool results and errors
   - Parallel tool execution

4. **Resource Management**
   - Listing available resources
   - Reading resource content
   - Subscribing to resource updates
   - Handling resource events

5. **Error Handling**
   - Error recovery strategies
   - Custom error handlers
   - Connection error handling

6. **Event System**
   - Server status events
   - Resource update events
   - Connection status events
   - Tool availability events