Table of contents

Thousands of companies trust Merge to accelerate AI from PoC to production.
Get a demo

How to connect a Notion MCP with Codex (4 steps)

Jon Gitlin
Senior Content Marketing Manager
at Merge

When you hand Codex a task, you usually paraphrase what's in Notion into the task description.

Codex then works from your interpretation instead of the spec itself.

Small omissions turn into wrong field names, missed edge cases, and code that compiles against assumptions rather than requirements.

To give Codex direct access to Notion as it works through your coding tasks, we'll show you how to connect Notion with Merge Agent Handler's Notion MCP server.

How it works

Merge Agent Handler connects Codex to Notion's API through the Merge CLI. You install the CLI, authenticate once, and run a single setup command from your project root.

That command writes a Merge CLI section to your project's AGENTS.md file, which tells Codex when to call merge search-tools and merge execute-tool to reach third-party services.

Once connected, Merge manages your Notion OAuth credentials and token refresh on your behalf, so no token state lives in your repo or local environment.

Related: How to use the Notion MCP in Claude Code

Prerequisites

Before getting started, you'll need the following:

  • A Merge Agent Handler account
  • Codex access (available via the OpenAI platform)
  • pipx installed (run pipx --version to confirm, or install via pip install pipx)
  • A Notion account with appropriate workspace permissions

If you want to connect Merge Agent Handler's Notion MCP with internal or customer-facing agentic products, you can follow the steps in our docs.

1. Install the Merge CLI

Install the Merge CLI with pipx: pipx install merge-api

Verify your installation: merge --version

2. Log in to Merge

Authenticate the CLI with your Merge Agent Handler account: merge login

This links the CLI to your account so Merge can make authorized requests against Notion on your behalf.

3. Add Agent Handler to Codex

Run the following from the root of the project where you want Codex to have access to Merge tools:

merge setup agents-md

This writes a Merge CLI section to your project's AGENTS.md file so Codex knows to use the CLI when it needs to call third-party services. The command is idempotent, so it's safe to re-run if you need to reset. Commit the updated AGENTS.md so the configuration travels with the repo.

Related: A guide to integrating the Notion MCP with Cursor

4. Authenticate Notion

Create a Codex task that requires Notion data, something like:

Read the Notion page titled "Billing API v2 spec" and scaffold the endpoint handlers and request and response types it describes.

The first time Codex invokes a Notion tool, a Magic Link will appear to complete connector authentication.

UI for authenticating Notion

{{this-blog-only-cta}}

Notion MCP FAQ

In case you have more questions on setting up and using the Notion MCP with Codex, we've addressed several more commonly-asked questions below.

What can you do once the Notion MCP is connected to Codex?

With Notion connected, Codex can:

  • Read a spec or PRD before scaffolding a feature: pull the requirements page from Notion so the generated code matches what the spec actually says, not a paraphrase of it
  • Pull a data dictionary before generating type definitions: read the page or database that documents fields and their types so Codex emits accurate models and enums
  • Read a runbook to structure a new module: fetch the operational doc so generated setup, teardown, and error handling follow the documented process
  • Turn a requirements page into test cases: pull the acceptance criteria from Notion so the tests Codex writes cover the real conditions
  • Pull an API reference page to scaffold an endpoint: read the documented request and response contract so generated handlers use the right shapes

Why use Merge Agent Handler vs. a self-hosted Notion MCP server?

You can self-host a Notion MCP server with open-source packages that wrap the Notion API. For a solo developer running local tasks against their own workspace, that setup works.

The overhead compounds once tasks run across a team and a shared repo.

Notion auth means managing integration tokens or OAuth credentials and keeping them fresh, and there's no built-in way to scope which pages, databases, or operations an autonomous agent can reach.

Merge Agent Handler centralizes authentication and adds a control layer on top.

You define which Notion operations Codex is allowed to call, Merge enforces those boundaries, and every tool call is logged with a full audit trail. For an agent that acts on its own, that scoping and observability is what makes the deployment defensible rather than just functional.

Why connect Notion to Codex?

Autonomous coding agents are only as accurate as the context they're given. When the source of truth is summarized into a task description, Codex fills the gaps with assumptions, and stale docs lead to wrong field names, invalid property types, and incorrect pagination logic.

Connecting Notion to Codex removes the guesswork. Codex reads the actual spec, schema, or runbook while it generates code, so its output reflects the current source instead of a paraphrase written days earlier.

Can I use Merge Agent Handler's Notion MCP with my employees?

Yes, Agent Handler for Employees is built to help organizations provision, secure, and govern how employees connect AI to tools like Notion.

Common patterns include:

  • Provisioning and access control via SCIM with identity providers like Okta and Microsoft Entra ID, so IT can manage which employees can read or edit Notion content by role or team
  • DLP and policy enforcement on tool calls, so admins can block retrieval of confidential pages or databases before results reach the employee's AI session
  • User-level audit logging so security and IT teams can review which pages were accessed or edited, by which employee identity, and when

Put together, employees can use the Notion MCP to read specs, generate code from requirements docs, query databases, and more, while IT keeps centralized control over which content and operations each identity can reach.

Jon Gitlin
Senior Content Marketing Manager
@Merge

Jon Gitlin is the Managing Editor of Merge's blog. He has several years of experience in the integration and automation space; before Merge, he worked at Workato, an integration platform as a service (iPaaS) solution, where he also managed the company's blog. In his free time he loves to watch soccer matches, go on long runs in parks, and explore local restaurants.

Read more

How Merge uplevels go-to-market execution with Agent Handler’s Gong connector

Company

AI gateway: overview, features, and top solutions

AI

How to connect a Box MCP with Claude Code (4 steps)

Insights

Subscribe to the Merge Blog

Get stories from Merge straight to your inbox

Subscribe

Connect Codex to thousands of tools with Merge Agent Handler

Use Merge Agent Handler’s 160+ connectors (including Notion) to power reliable, secure, and powerful agents.

Get started for free
But Merge isn’t just a Unified 
API product. Merge is an integration platform to also manage customer integrations.  gradient text
But Merge isn’t just a Unified 
API product. Merge is an integration platform to also manage customer integrations.  gradient text
But Merge isn’t just a Unified 
API product. Merge is an integration platform to also manage customer integrations.  gradient text
But Merge isn’t just a Unified 
API product. Merge is an integration platform to also manage customer integrations.  gradient text