Get the FREE Ultimate OpenClaw Setup Guide →

grammarly

MCP server for Grammarly AI detection and plagiarism scoring via Stagehand + Browserbase browser automation, with Claude-powered text optimization

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio bjornmelin-grammarly-mcp node dist/server.js \
  --env CLAUDE_MODEL="Claude model (e.g., auto, haiku, sonnet, opus)" \
  --env GOOGLE_MODEL="Google/Gemini model name (e.g., gemini-2.5-flash)" \
  --env OPENAI_MODEL="OpenAI model name (e.g., gpt-4o)" \
  --env CLAUDE_API_KEY="Claude API key (optional if claude login is used)" \
  --env OPENAI_API_KEY="OpenAI API key (optional)" \
  --env ANTHROPIC_MODEL="Anthropic model id when using direct Anthropic provider" \
  --env BROWSER_PROVIDER="stagehand (default) or browser-use" \
  --env IGNORE_SYSTEM_ENV="When true, ignores shell env vars and uses only .env file" \
  --env BROWSERBASE_API_KEY="API key for Browserbase (Stagehand provider)" \
  --env BROWSER_USE_API_KEY="API key for Browser Use Cloud (Browser Use Cloud provider)" \
  --env REWRITE_LLM_PROVIDER="LLM provider for text rewriting (e.g., claude-code, openai, google, anthropic)" \
  --env BROWSERBASE_CONTEXT_ID="Optional persistent context ID for Grammarly login" \
  --env BROWSERBASE_PROJECT_ID="Project ID for Browserbase" \
  --env BROWSERBASE_SESSION_ID="Optional existing session ID" \
  --env BROWSER_USE_PROFILE_ID="Profile ID for Browser Use Cloud with synced Grammarly login" \
  --env STAGEHAND_LLM_PROVIDER="LLM provider for browser automation (e.g., claude-code, openai, google, anthropic)" \
  --env GOOGLE_GEMINI_API_KEY_ALIAS="Alias or alternative key name for Gemini API if used" \
  --env GOOGLE_GENERATIVE_AI_API_KEY="Google Gemini API key (optional; also accepts GEMINI_API_KEY)"

How to use

This Grammarly MCP server automates Grammarly’s docs UI in a browser to derive AI-detection scores and plagiarism percentages, then can rewrite text using Claude to reduce detection risk. It exposes a single MCP tool named grammarly_optimize_text, which accepts prompts to inspect the text, run AI-detection checks, and apply rewrite operations. The server supports two browser automation providers: Stagehand + Browserbase (default) for higher reliability and session persistence, and Browser Use Cloud as a fallback for simpler setup. You can run the server via Node.js, pointing to dist/server.js after building, and configure credentials for the chosen provider. The output is designed to be structured (JSON or markdown) for easy integration into MCP clients.

How to install

Prerequisites:

  • Node.js 18+
  • pnpm (recommended) or npm
  • Grammarly Pro account
  • Claude Code CLI for text rewriting

Installation steps:

  1. Clone the repository: git clone https://github.com/BjornMelin/grammarly-mcp.git cd grammarly-mcp

  2. Install dependencies and build: pnpm install pnpm build

  3. Install Claude Code CLI (for text rewriting): npm install -g @anthropic-ai/claude-code claude login

  4. Create and configure environment file (example): cp .env.example .env

    Edit .env with your provider credentials and preferences

  5. Run or register with MCP client:

    If using Claude Code integration, follow the project's instructions to add Grammarly tool and route to node dist/server.js

    Example (depending on your MCP setup): claude mcp add grammarly -- node $(pwd)/dist/server.js

Additional notes

Environment variables govern provider choice and authentication. The default provider is Stagehand with Browserbase; ensure API keys and project IDs are set. If you switch to Browser Use Cloud, provide BROWSER_USE_API_KEY and BROWSER_USE_PROFILE_ID. For text rewriting, Claude Code is used; make sure claude login is completed. The server can emit live debug URLs per task and supports action caching if configured. If you encounter login issues with Grammarly, use the Session ID or Context ID features to persist sessions. The tool grammarly_optimize_text focuses on improving text to reduce AI detection while preserving meaning. Ensure you comply with Grammarly's terms of service and applicable usage policies.

Related MCP Servers

Sponsor this space

Reach thousands of developers