home / mcp / grammarly mcp server

Grammarly MCP Server

A single-tool MCP server that analyzes Grammarly AI detection and plagiarism scores via browser automation and text rewriting.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "bjornmelin-grammarly-mcp": {
      "command": "node",
      "args": [
        "/path/to/grammarly-mcp/dist/server.js"
      ],
      "env": {
        "BROWSER_PROVIDER": "stagehand",
        "BROWSERBASE_API_KEY": "bb_xxx",
        "BROWSERBASE_CONTEXT_ID": "ctx_xxx",
        "BROWSERBASE_PROJECT_ID": "xxx"
      }
    }
  }
}

You can run a self-contained MCP server named Grammarly that automates Grammarly’s web UI to assess AI-detection and plagiarism scores, and then rewrites text to reduce detection using Claude. You access it through a simple MCP client workflow and control it via environment variables. This enables automated scoring, optional rewriting, and structured outputs for your text optimization needs.

How to use

Use an MCP client to connect to the Grammarly MCP Server and invoke the grammarly_optimize_text tool. Set your environment to use Stagehand with Browserbase by default for reliable sessions and persistent login contexts, or switch to Browser Use Cloud if you already have that setup. Provide the text you want analyzed and, if needed, specify the rewriting preferences such as tone, domain, and iterations. The server will first score the original text, then, if you enable optimize mode, iterate rewriting and re-scoring until the thresholds for AI detection and plagiarism are met or until the maximum iterations are reached. The output includes the final text, scores, and a live URL for debugging when available.

How to install

Follow these concrete steps to install and run the Grammarly MCP Server locally.

Prerequisites you need on your system:

  • Node.js 18+ is required
  • NPM or PNPM for package management
  • Claude Code CLI for text rewriting (optional but recommended)

Install and run the server

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

# 2. Install dependencies
pnpm install

# 3. Build the server
pnpm build

# 4. Run the server locally (stdio MCP transport)
pnpm start
# or
node dist/server.js

Configure provider and credentials

Choose a browser automation provider. The default is Stagehand + Browserbase. You can fall back to Browser Use Cloud if you have that setup. You must supply credentials for the chosen provider in your environment. The minimal, recommended setup uses Stagehand with Browserbase and includes your Browserbase API key, project ID, and the provider setting.

# Minimal example config (Stagehand + Browserbase)
{
  "env": {
    "BROWSER_PROVIDER": "stagehand",
    "BROWSERBASE_API_KEY": "bb_xxx",
    "BROWSERBASE_PROJECT_ID": "xxx"
  }
}
```

```
# Optional: add context for persistent login (if you have this handy)
{
  "env": {
    "BROWSER_PROVIDER": "stagehand",
    "BROWSERBASE_API_KEY": "bb_xxx",
    "BROWSERBASE_PROJECT_ID": "xxx",
    "BROWSERBASE_CONTEXT_ID": "ctx_xxx"
  }
}

Client configuration and usage

Configure your MCP client to point at the local server. You will typically run the server with Node and pass the server script path as an argument. The client configuration can be done through interactive setup or by manual config in your MCP client of choice.

# Claude Code CLI example (manual)
claude mcp add grammarly -e BROWSER_PROVIDER=stagehand \
  -e BROWSERBASE_API_KEY=bb_xxx \
  -e BROWSERBASE_PROJECT_ID=xxx \
  -- node /path/to/grammarly-mcp/dist/server.js
```

```
# Claude Desktop / other clients
# Add a server with the same env values and the same node command
{
  "mcpServers": {
    "grammarly": {
      "command": "node",
      "args": ["/path/to/grammarly-mcp/dist/server.js"],
      "env": {
        "BROWSER_PROVIDER": "stagehand",
        "BROWSERBASE_API_KEY": "bb_xxx",
        "BROWSERBASE_PROJECT_ID": "xxx"
      }
    }
  }
}

Tool: grammarly_optimize_text

This server exposes a single tool named grammarly_optimize_text that analyzes and optimizes text for Grammarly AI detection and plagiarism scores. You can configure the mode, thresholds, tone, and iterations to control how aggressively rewriting occurs.

Environment variables and configuration details

The server supports two browser automation providers. By default you use Stagehand with Browserbase. You can switch to Browser Use Cloud if you have that setup.

Environment variables you will commonly set when using Stagehand with Browserbase include the API key and project ID, along with the provider selection. You can also enable a persistent login context if desired.

Security and best practices

Treat API keys and session data as sensitive. Do not commit credentials to version control. Use per-project or per-environment configurations, and consider context IDs for Browserbase to keep Grammarly login state across runs. Review data flow: automation server -> Grammarly web UI -> Claude for rewriting.

Notes and troubleshooting

If the server fails to start, verify that required environment variables are set for your chosen provider. If a tool does not appear in your client, ensure the server path is correct and that you rebuilt the project after changes.

If you encounter login persistence issues with Browserbase, ensure you logged in while the context was active and that the context ID matches the session. For Browser Use Cloud, verify your API key and that the profile is properly synced.

Notes on usage limits and reliability

UI automation depends on Grammarly’s web UI stability. Stagehand provides self-healing capabilities, while Browser Use Cloud offers a different approach with per-task debugging. Respect usage limits of each provider and plan for potential adjustments when UI changes occur.

Available tools

grammarly_optimize_text

Tool that analyzes AI detection and plagiarism scores for given text and can rewrite text to reduce detection, with configurable mode, thresholds, tone, and iterations.