grammarly
MCP server for Grammarly AI detection and plagiarism scoring via Stagehand + Browserbase browser automation, with Claude-powered text optimization
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:
-
Clone the repository: git clone https://github.com/BjornMelin/grammarly-mcp.git cd grammarly-mcp
-
Install dependencies and build: pnpm install pnpm build
-
Install Claude Code CLI (for text rewriting): npm install -g @anthropic-ai/claude-code claude login
-
Create and configure environment file (example): cp .env.example .env
Edit .env with your provider credentials and preferences
-
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
pilot-shell
The professional development environment for Claude Code. Claude Code is powerful. Pilot Shell makes it reliable. Start a task, grab a coffee, come back to production-grade code. Tests enforced. Context preserved. Quality automated.
lc2mcp
Convert LangChain tools to FastMCP tools
mcp-task-orchestrator
A Model Context Protocol server that provides task orchestration capabilities for AI assistants
automagik-tools
From API to AI in 30 Seconds - Transform any API into an intelligent MCP agent that learns, adapts, and speaks human
cadre-ai
Your AI agent squad for Claude Code. 17 specialized agents, persistent memory, desktop automation, and a common sense engine.
claude-persistent-memory
Give Claude Code persistent memory across sessions. Hybrid BM25 + vector semantic search, auto-structuring via LLM, and 4-channel retrieval (MCP + hooks). Your AI assistant finally remembers.