Skip to main content
You’re likely using AI to write code, and there’s a right and wrong way to do it. This page collects the rules, configs, and copy-paste snippets that get your coding assistant writing correct Stagehand v4 code.

Quickstart

Add MCP servers

Configure Context7, DeepWiki, and Stagehand Docs in your MCP client.

Pin editor rules

Drop in cursorrules and claude.md so AI agents/assistants always emit Stagehand patterns.

Using MCP servers

MCP (Model Context Protocol) servers act as intermediaries that connect AI systems to external data sources and tools. These servers enable your coding assistant to access real-time information, execute tasks, and retrieve structured data to enhance code generation accuracy. The following MCP servers provide specialized access to Stagehand documentation and related resources:
Provides semantic search across documentation and codebase context. Context7 enables AI assistants to find relevant code patterns, examples, and implementation details from your project history. It maintains contextual understanding of your development workflow and can surface related solutions from previous work.Installation:
Indexes GitHub repositories and their documentation. DeepWiki gives coding assistants access to repository structure, API references, and code relationships across the Stagehand repository.Installation:
Direct access to official Stagehand documentation. This MCP server provides AI assistants with up-to-date API references, configuration options, and usage examples for accurate code generation. Mintlify auto-generates this server from the official docs, ensuring your AI assistant always has the latest information.Usage:
How MCP servers enhance your development:
  • Real-time Documentation Access: AI assistants can query the latest Stagehand docs, examples, and best practices
  • Context-Aware Code Generation: Servers provide relevant code patterns and configurations based on your specific use case
  • Reduced Integration Overhead: Standardized protocol eliminates the need for custom integrations with each documentation source
  • Enhanced Accuracy: AI agents receive structured, up-to-date information rather than relying on potentially outdated training data
Prompting tip: Explicitly ask your coding agent/assistant to use these MCP servers to fetch relevant information from the docs so they have better context and know how to write proper Stagehand code.ie. “Use the stagehand-docs MCP to fetch the act/observe guidelines, then generate code that follows them. Prefer cached observe results.”

Editor rule files (copy-paste)

Drop these in .cursorrules, windsurfrules, claude.md, or any agent rule framework:

Security notes

  • Do not embed secrets in docs or rule files; use environment variables in MCP configs.
  • Pass secrets through variables so they are substituted locally and never sent to the model provider.
  • Set logging.level to "off" when handling sensitive data so nothing sensitive reaches your logs.
  • Avoid broad actions that may trigger unintended navigation; prefer observe first.

Resources/references