Notion Terminal MCP
Allows Notion Custom Agents to execute terminal commands and manage files on the host machine through MCP tools.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Notion Terminal MCPlist the files in the workspace"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Notion Terminal MCP
An authenticated, production-ready remote Model Context Protocol (MCP) server providing Terminal Execution and Filesystem Tools to Notion Custom Agents, Claude, Cursor, and autonomous AI agents over Streamable HTTP.
Includes built-in zero-config public tunneling via the official Ngrok Node.js SDK (@ngrok/ngrok).
Features
ā” Streamable HTTP Transport: Modern MCP server implementation running on Express.
š Built-in Ngrok Tunnel: Expose your local MCP server to Notion with a single command (
npm run startornpm run dev) using@ngrok/ngrok.š» Terminal Execution: Execute PowerShell or cmd commands with configurable timeouts, working directories, and recursive process tree termination.
š Filesystem Operations: Full set of tools for reading, writing, moving, listing, statting, and deleting files and directories.
š Security & Sandboxing:
Sandboxed Mode (
FULL_ACCESS=false): Strict path containment inside a configuredFILES_ROOTwith path traversal defense.Full Host Mode (
FULL_ACCESS=true): Unrestricted access when you need full host automation.Timing-Safe Auth: Constant-time comparison (
crypto.timingSafeEqual) for Bearer tokens and API keys.Host Header Validation: Prevents DNS rebinding and unauthorized host header spoofing.
š¤ Agent-First Design: Detailed specifications and JSON schemas optimized for AI models (AGENT_SPEC.md).
Quick Start
1. Installation
Clone the repository and install dependencies:
git clone https://github.com/Speedstu/notion-terminal-mcp.git
cd notion-terminal-mcp
npm install2. Environment Setup
Copy .env.example to .env or run the setup script:
# Automated setup (generates a secure 32+ character API key)
.\setup.ps1Or manually:
Copy-Item .env.example .env
# Generate a secure token:
npm run tokenEdit your .env file:
# Required: Secure API Key for Notion
MCP_API_KEY=your_generated_32_char_api_key
PORT=3000
HOST=127.0.0.1
# Ngrok Public Tunnel (Optional but recommended for Notion)
NGROK_ENABLED=true
NGROK_AUTHTOKEN=your_ngrok_authtoken_here
NGROK_DOMAIN=your-static-name.ngrok-free.app
# Security & Sandboxing
FULL_ACCESS=false
FILES_ROOT=./workspace
ALLOWED_HOSTS=localhost:3000;127.0.0.1:3000;*.ngrok-free.app;*.ngrok.app;*.ngrok-free.dev3. Build & Run
# Build TypeScript
npm run build
# Start production server
npm run startFor development with hot reload:
npm run devWhen started with NGROK_ENABLED=true, the server will output connection details ready to paste into Notion:
============================================================
NOTION MCP AGENT CONNECTION READY
============================================================
URL to paste into Notion: https://your-domain.ngrok-free.app/mcp
Authentication Header:
Header Name: Authorization
Header Value: Bearer <your_token>
============================================================Connecting to Notion Custom Agents
In Notion, open Settings & members ā Connections (or open your Notion Agent configuration).
Add a new Custom MCP Connection.
Set Server URL to:
https://your-domain.ngrok-free.app/mcpSet Authentication:
Header Name:
AuthorizationHeader Value:
Bearer <YOUR_MCP_API_KEY>
Test the connection. Notion will automatically discover all 7 tools (
terminal_execute,file_read,file_write,file_list,file_stat,file_mkdir,file_move,file_delete).
Available MCP Tools
See AGENT_SPEC.md for full JSON schemas, parameters, and return types.
Tool | Description |
| Execute PowerShell or cmd commands with UTF-8 encoding and timeout options. |
| Search files by name glob ( |
| Safely replace an exact block of code or text in a file without rewriting it completely. |
| Read file contents (UTF-8 or Base64) with offset pagination for large files. |
| Create, overwrite, or append content to files (creates missing directories). |
| List directory contents recursively or flat with file sizes. |
| Inspect file/directory metadata (size, created/modified timestamps, mode). |
| Create directories recursively. |
| Move or rename files and directories. |
| Safely delete files or directories ( |
Configuration Reference (.env)
Variable | Default | Description |
| required | Secret key for authentication (min 32 characters). |
|
| Port for the HTTP server. |
|
| Host address to bind to. |
|
| Enable/disable automatic ngrok tunnel creation on start. |
|
| Ngrok authtoken (optional if configured globally via ngrok CLI). |
|
| Static/custom ngrok domain (e.g. |
|
| Semicolon-separated list of allowed |
|
| When |
|
| Base directory for the sandbox when |
|
| Default timeout for terminal commands (2 minutes). |
|
| Max stdout/stderr capture size (1 MB). |
|
| Max file size read/write limit per request (10 MB). |
Project Structure
notion-terminal-mcp/
āāā src/
ā āāā config.ts # Type-safe environment and validation
ā āāā index.ts # Server entry point & lifecycle
ā āāā server.ts # Express setup & MCP Streamable HTTP endpoint
ā āāā middleware/
ā ā āāā auth.ts # Timing-safe token authentication
ā ā āāā host.ts # Host header validation
ā āāā tools/
ā ā āāā command.ts # Process tree management & execution
ā ā āāā filesystem.ts # Sandboxed filesystem CRUD operations
ā ā āāā index.ts # MCP tool registrations
ā ā āāā types.ts # MCP result helpers & interfaces
ā āāā tunnel/
ā āāā ngrok.ts # Ngrok SDK manager & Notion connection banner
āāā AGENT_SPEC.md # Technical specification for AI Agents
āāā package.json
āāā tsconfig.json
āāā setup.ps1 # PowerShell initial setup scriptNPM Scripts
npm run buildā Compile TypeScript todist/.npm run startā Run production server fromdist/index.js.npm run devā Run development server withtsx watch.npm run checkā Type-check TypeScript without emitting files.npm run tokenā Generate a cryptographically secure random token forMCP_API_KEY.
Security Policy
Please review SECURITY.md for security considerations and vulnerability reporting guidelines.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.
StremAI MCP: shared memory for AI coding agents. Connected agents can recall. OAuth + local stdio.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Glebsky/notion-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server