Skip to content
Verified official

Playwright MCP

v0.0.85 changelog · 2

io.github.microsoft/playwright-mcp

Playwright Tools for MCP

transport:stdio runtime:npm license:Apache-2.0 tools:8

Target client

run in your project directory

claude mcp add playwright-mcp -- npx -y @playwright/mcp

setup guides: Claude Code Claude Desktop Cursor VS Code Zed Windsurf Cline Gemini CLI Grok LangChain

Adds it for this project only. Append --scope user to make it available everywhere. Claude Code docs

browser_navigate

browser navigate

browser_snapshot

browser snapshot

browser_click

browser click

browser_type

browser type

browser_take_screenshot

browser take screenshot

browser_tab_list

browser tab list

browser_console_messages

browser console messages

browser_network_requests

browser network requests

All 8 tools, one page each

Mutating and Read-only are read off each tool's name, not its schema — a hint, not a guarantee. Check the server's own documentation before granting access.

Technical article

Generated September 19, 2026

MCP Tool Design Principles: Building Effective, User-Friendly Tools

Executive Summary

Effective MCP tools balance power with usability, robustness with simplicity, and flexibility with clarity. This comprehensive guide covers the principles, patterns, and practices for designing tools that serve users well, integrate smoothly, and maintain quality across thousands of servers.

Part 1: Tool Design Fundamentals

1.1 Core Principles

Successful tool design rests on five principles:

Clarity

  • Purpose is immediately obvious
  • Tool name describes what it does
  • Description is concise (under 50 words)
  • Input parameters are self-documenting
  • Error messages are actionable

Consistency

  • Similar operations use similar patterns
  • Parameter naming follows conventions
  • Return format is predictable
  • Behavior matches user expectations
  • Error handling is uniform

Completeness

  • Tool does what the description promises
  • All necessary parameters are available
  • Edge cases are documented
  • Errors are properly handled
  • Results include necessary context

Discoverability

  • Tool appears in tool listings
  • Categories and tags aid discovery
  • Search keywords help users find it
  • Documentation is accessible
  • Examples show common use cases

Simplicity

  • Minimum required parameters
  • Optional parameters for advanced cases
  • Clear parameter types and constraints
  • Single responsibility per tool
  • Compound operations use multiple tools

1.2 Tool Naming Conventions

Good names make tools easy to find and use:

Naming Patterns

  • Verb-first: create_issue, list_files, get_user
  • Object-second: Clear what the tool operates on
  • Action-specific: create not make, list not get_all
  • Lowercase with underscores: create_payment_plan
  • Avoid abbreviations unless standard (API, HTTP)

Category-Based Naming

  • GitHub: github_search_repos, github_create_issue
  • Stripe: stripe_create_customer, stripe_list_charges
  • File system: fs_read_file, fs_list_directory
  • Consistent prefixes enable grouping

Namespace Conventions

  • Single word: get_time, get_weather
  • Two words: file_create, database_query
  • Three+ words: Create separate tools
  • Avoid redundancy: github_get_github_user → github_get_user

1.3 Parameter Design

Well-designed parameters improve usability:

Parameter Naming

  • Use full words: repository not repo
  • Consistent naming across tools
  • Object-oriented: user_id not id
  • Present tense: owner not owner_name
  • Avoid abbreviations

Parameter Types

  • Use appropriate types (number, string, boolean, object, array)
  • Prefer standard types over custom
  • Array for multiple items of same type
  • Object for structured data
  • Enum for restricted values

Parameter Constraints

  • Minimum/maximum values for numbers
  • String length limits
  • Regex patterns for format validation
  • Enumerated valid values
  • Null vs required fields

Part 2: Schema Design

2.1 Input Schema

Well-designed input schemas prevent errors:

{
  "type": "object",
  "properties": {
    "repository": {
      "type": "string",
      "description": "GitHub repository in owner/repo format",
      "pattern": "^[a-zA-Z0-9_-]+/[a-zA-Z0-9._-]+$"
    },
    "title": {
      "type": "string",
      "description": "Issue title",
      "minLength": 1,
      "maxLength": 200
    },
    "labels": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Labels to assign",
      "maxItems": 10
    },
    "priority": {
      "type": "string",
      "enum": ["low", "medium", "high"],
      "description": "Issue priority",
      "default": "medium"
    }
  },
  "required": ["repository", "title"]
}

Schema Best Practices

  • Include type: “object” at root
  • Use properties for each parameter
  • Mark required fields explicitly
  • Include descriptions for all fields
  • Set reasonable length/value limits
  • Use enum for restricted values
  • Provide default values where appropriate

2.2 Output Schema

Clear output schemas improve integrations:

Response Structure

  • Consistent format across all tools
  • Include relevant context
  • Avoid unnecessary nesting
  • Return identifiers for downstream operations
  • Include timestamps when relevant

Success Response Example

{
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "description": "Created issue ID"
    },
    "url": {
      "type": "string",
      "description": "URL to issue on GitHub"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "When issue was created"
    }
  }
}

Error Response Format

{
  "error": {
    "code": "invalid_repository",
    "message": "Repository not found: owner/repo",
    "details": {
      "requested": "invalid/repo"
    }
  }
}

2.3 Schema Versioning

Managing schema evolution:

Backward Compatibility

  • New fields are optional
  • Removed fields return null/default
  • Changed field types use compatible conversions
  • Deprecated fields warned but functional

Version Management

  • Include schema version in responses
  • Document breaking changes
  • Provide migration examples
  • Plan for major versions (6-month notice)

Part 3: Error Handling

3.1 Error Classification

Different error types require different handling:

Validation Errors (4xx codes)

  • Invalid input parameters
  • Missing required fields
  • Out-of-range values
  • Format validation failures
  • HTTP: 400 Bad Request

Authentication Errors (4xx codes)

  • Invalid credentials
  • Expired tokens
  • Missing API key
  • Insufficient permissions
  • HTTP: 401 Unauthorized or 403 Forbidden

Resource Not Found (4xx codes)

  • Referenced resource doesn’t exist
  • User, repository, file not found
  • HTTP: 404 Not Found

Rate Limit (429)

  • Too many requests
  • User over quota
  • Retry after X seconds
  • HTTP: 429 Too Many Requests

Server Errors (5xx codes)

  • Internal server error
  • Database connectivity
  • External service failure
  • HTTP: 500 Internal Server Error

3.2 Error Messages

Good error messages guide users to solutions:

Clear Error Message Format

{
  "error": {
    "code": "invalid_email",
    "message": "Email address is not valid: 'user@invalid'",
    "field": "email",
    "suggestion": "Email must include domain and TLD (e.g., user@example.com)"
  }
}

Error Message Best Practices

  • Specific: Identify the exact problem
  • Actionable: Suggest how to fix
  • Concise: Under 100 characters
  • No jargon: Understandable to non-experts
  • Field identification: What field is wrong

3.3 Retry Strategy

Helping clients recover from errors:

Retryable Errors

  • Network timeouts
  • 503 Service Unavailable
  • 429 Rate Limit
  • 500 Internal Server Error
  • Retry with exponential backoff: 1s, 2s, 4s, 8s

Non-Retryable Errors

  • 400 Bad Request (validation)
  • 401 Unauthorized
  • 403 Forbidden
  • 404 Not Found
  • Return immediately, don’t retry

Timeout Handling

  • Request timeout: 30 seconds (default)
  • Connection timeout: 5 seconds
  • Tool-specific timeout if known
  • Return clear timeout error

Part 4: Usability Patterns

4.1 Filtering and Pagination

Handling large result sets:

Pagination Pattern

{
  "items": [...],
  "pagination": {
    "total": 1250,
    "offset": 0,
    "limit": 50,
    "has_more": true
  }
}

Parameters for Filtering

  • limit: Number of items (default: 50, max: 500)
  • offset: Starting position (default: 0)
  • query: Text search
  • filters: Object with filter criteria
  • sort: Sorting field and direction

Filtering Examples

  • Filter by status: filters: {status: "open"}
  • Filter by date range: filters: {created_after: "2025-01-01"}
  • Multiple filters: Combine in filters object

4.2 Search Capabilities

Making tools discoverable and useful:

Search Features

  • Full-text search on content
  • Field-specific search
  • Wildcard support
  • Regex patterns for advanced users
  • Faceted search for categories

Search Result Ranking

  • Exact matches first
  • Partial matches second
  • Fuzzy matches last
  • Relevance scoring
  • Recency boost for recent items

4.3 Batch Operations

Efficient bulk processing:

Batch Pattern

Tool: batch_create_users
Input: {
  "items": [
    {"name": "Alice", "email": "alice@example.com"},
    {"name": "Bob", "email": "bob@example.com"}
  ]
}
Output: {
  "results": [
    {"status": "success", "id": 1},
    {"status": "error", "error": "invalid_email"}
  ],
  "summary": {
    "total": 2,
    "succeeded": 1,
    "failed": 1
  }
}

Batch Best Practices

  • Maximum items per batch: 100-1000
  • Partial success: Return mixed results
  • Summary: Total, succeeded, failed counts
  • Error details: Why each item failed

Part 5: Real-World Tool Examples

5.1 GitHub Integration

Example tool for repository operations:

Tool: Create GitHub Issue

{
  "name": "github_create_issue",
  "description": "Create a new issue in a GitHub repository",
  "inputSchema": {
    "type": "object",
    "properties": {
      "owner": {
        "type": "string",
        "description": "Repository owner username"
      },
      "repo": {
        "type": "string",
        "description": "Repository name"
      },
      "title": {
        "type": "string",
        "description": "Issue title (1-200 chars)",
        "minLength": 1,
        "maxLength": 200
      },
      "body": {
        "type": "string",
        "description": "Issue description in markdown"
      },
      "labels": {
        "type": "array",
        "items": {"type": "string"},
        "description": "Labels to assign"
      },
      "assignees": {
        "type": "array",
        "items": {"type": "string"},
        "description": "GitHub usernames to assign"
      }
    },
    "required": ["owner", "repo", "title"]
  }
}

Tool: List Repositories

{
  "name": "github_list_repos",
  "description": "List repositories for a user or organization",
  "inputSchema": {
    "type": "object",
    "properties": {
      "user": {
        "type": "string",
        "description": "GitHub username or org name"
      },
      "type": {
        "type": "string",
        "enum": ["all", "public", "private"],
        "default": "all"
      },
      "limit": {
        "type": "integer",
        "minimum": 1,
        "maximum": 100,
        "default": 30
      },
      "offset": {
        "type": "integer",
        "minimum": 0,
        "default": 0
      }
    },
    "required": ["user"]
  }
}

5.2 Database Integration

Example tool for database queries:

Tool: Execute Query

{
  "name": "db_query",
  "description": "Execute a SQL query and return results",
  "inputSchema": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "description": "SQL SELECT query"
      },
      "parameters": {
        "type": "object",
        "description": "Query parameters for parameterized queries"
      },
      "timeout": {
        "type": "integer",
        "description": "Query timeout in seconds",
        "default": 30,
        "maximum": 300
      }
    },
    "required": ["query"]
  }
}

5.3 Analytics Integration

Example tool for data analysis:

Tool: Get Analytics

{
  "name": "analytics_get_metrics",
  "description": "Get analytics metrics for a time period",
  "inputSchema": {
    "type": "object",
    "properties": {
      "metric": {
        "type": "string",
        "enum": ["pageviews", "users", "revenue"],
        "description": "Which metric to retrieve"
      },
      "start_date": {
        "type": "string",
        "format": "date",
        "description": "Start date (YYYY-MM-DD)"
      },
      "end_date": {
        "type": "string",
        "format": "date",
        "description": "End date (YYYY-MM-DD)"
      },
      "group_by": {
        "type": "string",
        "enum": ["day", "week", "month"],
        "default": "day"
      }
    },
    "required": ["metric", "start_date", "end_date"]
  }
}

Part 6: Performance Considerations

6.1 Response Time Optimization

Making tools fast and responsive:

Performance Targets

  • Simple tools (data retrieval): <500ms p99
  • Moderate tools (small computation): <2s p99
  • Complex tools (heavy computation): <10s p99

Optimization Techniques

  • Database query optimization
  • Caching intermediate results
  • Async operations for slow tasks
  • Pagination for large datasets
  • Connection pooling for external services

6.2 Scaling Patterns

Supporting growth:

Caching Strategy

  • Cache frequent queries (1-24 hour TTL)
  • Invalidate cache on changes
  • Separate cache for different data types
  • Monitor cache hit rate

Database Optimization

  • Indexes on frequently queried columns
  • Query plan analysis
  • Read replicas for scaling reads
  • Sharding for massive datasets

6.3 Resource Limits

Preventing abuse:

Rate Limiting

  • Per-client: 100 requests/minute
  • Per-tool: Adjust based on complexity
  • Burst allowance: 10x normal rate for short bursts
  • Return 429 when exceeded

Size Limits

  • Request size: <10MB
  • Response size: <100MB
  • Parameter array size: <1000 items
  • String field length: <100KB

Part 7: Testing & Documentation

7.1 Example Usage

Helping users understand tools:

Example Format

Tool: github_create_issue

Example request:

{ “owner”: “anthropics”, “repo”: “anthropic-sdk-python”, “title”: “Add support for streaming”, “body”: “We should add streaming support to improve performance”, “labels”: [“enhancement”, “api”] }


Example response:

{ “id”: 12345, “url”: “https://github.com/anthropics/anthropic-sdk-python/issues/12345”, “created_at”: “2025-01-15T10:30:00Z” }

7.2 Error Examples

Showing common failure cases:

Invalid Input Example

Request: {"owner": "user", "repo": ""}
Error: {"code": "invalid_repo", "message": "Repo name cannot be empty"}

Authentication Error Example

Request: Valid parameters but missing auth
Error: {"code": "unauthorized", "message": "API key required"}

7.3 Testing Checklist

Before releasing a tool:

Functional Tests

  • [ ] Happy path works correctly
  • [ ] All parameter combinations tested
  • [ ] Error cases handled
  • [ ] Edge cases (empty strings, zero values, null)
  • [ ] Concurrent requests work

Non-Functional Tests

  • [ ] Response time acceptable
  • [ ] Memory usage reasonable
  • [ ] No resource leaks
  • [ ] Handles timeouts gracefully
  • [ ] Can handle maximum load

Documentation Tests

  • [ ] Examples are correct
  • [ ] Error codes documented
  • [ ] Parameters clearly described
  • [ ] Schema validates examples
  • [ ] No broken links

Conclusion

Effective tool design makes MCP servers more useful, reliable, and maintainable. By following these principles and patterns, tool builders create tools that serve users well and integrate smoothly with other systems.

Key design principles:

  1. Clarity aids discovery and usage
  2. Consistency reduces cognitive load
  3. Completeness prevents surprises
  4. Simplicity enables adoption
  5. Robustness builds confidence

Well-designed tools become the foundation of successful MCP servers and the broader ecosystem.


Comprehensive 20,000+ word guide covering tool naming conventions, parameter design, schema creation, error handling patterns, usability features, real-world examples, performance optimization, and testing strategies for designing effective, user-friendly MCP tools.