TESTING.md•5.62 kB
# Testing Guide for Google Slides MCP Server
This guide provides multiple ways to test your Google Slides MCP server.
## Prerequisites
1. **Build the project first:**
```bash
npm run build
```
2. **Set up Google OAuth2 credentials** (you've already done this in your `.env` file)
3. **Create a test Google Slides presentation:**
- Go to [Google Slides](https://slides.google.com)
- Create a new presentation
- Copy the presentation ID from the URL (the long string after `/presentation/d/`)
## Testing Methods
### Method 1: Using the Test Client (Recommended)
I've created a simple test client for you:
```bash
node test-client.js
```
This interactive client will:
1. Start the MCP server
2. List available tools
3. Walk you through the OAuth authentication flow
4. Test creating slides and adding rectangles
### Method 2: Manual JSON-RPC Testing
You can test the server manually by sending JSON-RPC messages via stdin/stdout:
1. **Start the server:**
```bash
npm start
```
2. **Send JSON-RPC requests** (paste these one by one):
**Initialize the connection:**
```json
{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2024-11-05", "capabilities": {"tools": {}}, "clientInfo": {"name": "test", "version": "1.0.0"}}}
```
**List available tools:**
```json
{"jsonrpc": "2.0", "id": 2, "method": "tools/list"}
```
**Get authentication URL:**
```json
{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "get_auth_url", "arguments": {}}}
```
**Authenticate (replace with your auth code):**
```json
{"jsonrpc": "2.0", "id": 4, "method": "tools/call", "params": {"name": "authenticate", "arguments": {"code": "YOUR_AUTH_CODE_HERE"}}}
```
**Create a slide (replace with your presentation ID):**
```json
{"jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": {"name": "create_slide", "arguments": {"presentationId": "YOUR_PRESENTATION_ID"}}}
```
**Add rectangle (replace with your presentation and slide IDs):**
```json
{"jsonrpc": "2.0", "id": 6, "method": "tools/call", "params": {"name": "add_rectangle", "arguments": {"presentationId": "YOUR_PRESENTATION_ID", "slideId": "YOUR_SLIDE_ID"}}}
```
### Method 3: Using an MCP Client
If you have an MCP-compatible client (like Claude Desktop with MCP support), you can register this server:
1. **Add to your MCP client configuration** (example for Claude Desktop):
```json
{
"mcpServers": {
"google-slides": {
"command": "node",
"args": ["/path/to/your/project/dist/index.js"]
}
}
}
```
## Step-by-Step Testing Process
### 1. Authentication Flow
1. **Get the auth URL:**
- Call the `get_auth_url` tool
- Copy the returned URL
2. **Complete OAuth flow:**
- Open the URL in your browser
- Sign in to Google and grant permissions
- You'll be redirected to a localhost URL with a `code` parameter
- Copy the code from the URL
3. **Authenticate:**
- Call the `authenticate` tool with the code
- The server will save your tokens for future use
### 2. Basic Operations
1. **Get presentation info:**
```bash
# Replace with your presentation ID
{"name": "get_presentation_info", "arguments": {"presentationId": "1BxAB07047kHMdtbgoC48KDz3YMgn9_YOUR_ID"}}
```
2. **List existing slides:**
```bash
{"name": "list_slides", "arguments": {"presentationId": "YOUR_PRESENTATION_ID"}}
```
3. **Create a new slide:**
```bash
{"name": "create_slide", "arguments": {"presentationId": "YOUR_PRESENTATION_ID"}}
```
4. **Add a rectangle to the slide:**
```bash
{"name": "add_rectangle", "arguments": {"presentationId": "YOUR_PRESENTATION_ID", "slideId": "RETURNED_SLIDE_ID"}}
```
## Finding Your Presentation ID
1. Open your Google Slides presentation
2. Look at the URL: `https://docs.google.com/presentation/d/PRESENTATION_ID_HERE/edit`
3. Copy the long string between `/d/` and `/edit`
Example:
- URL: `https://docs.google.com/presentation/d/1BxAB07047kHMdtbgoC48KDz3YMgn9_abcdefgh/edit`
- Presentation ID: `1BxAB07047kHMdtbgoC48KDz3YMgn9_abcdefgh`
## Expected Results
### Creating a Slide
- **Success:** Returns a message with the new slide ID
- **Error:** Check that you have edit permissions on the presentation
### Adding a Rectangle
- **Success:** Returns a message with the rectangle ID
- **Result:** You should see a rectangle on the slide that is 20% the size of the slide dimensions, centered on the slide
## Troubleshooting
### Common Issues
1. **"Not authenticated" error:**
- Run the authentication flow first
- Check that your `.env` file has the correct OAuth credentials
2. **"Presentation not found" error:**
- Verify the presentation ID is correct
- Ensure you have edit access to the presentation
3. **"Invalid slide ID" error:**
- Make sure you're using a slide ID that exists
- Use the `list_slides` tool to get valid slide IDs
### Debug Mode
Enable debug mode in your `.env` file:
```env
DEBUG=true
```
This will provide more detailed logging output.
## Verification
After testing, check your Google Slides presentation to verify:
1. New slides were created
2. Rectangles were added to the specified slides
3. Rectangles are properly sized (20% of slide dimensions)
4. Rectangles are positioned correctly (centered by default)
## Next Steps
Once basic testing works, you can:
1. Test with different presentation IDs
2. Try custom positioning for rectangles
3. Test error handling with invalid IDs
4. Integrate with your preferred MCP client