Notion
Search pages and databases in Notion
The Notion integration provides access to Notion's API through the Integrate MCP server.
Installation
The Notion integration is included with the SDK:
import { notionIntegration } from "integrate-sdk/server";Setup
1. Create a Notion Integration
- Go to Notion Integrations
- Create a new integration
- Note your OAuth Client ID and Client Secret
- Configure capabilities (read content, update content, etc.)
2. Configure the Integration on Your Server
Add the Notion integration to your server configuration. The integration automatically reads NOTION_CLIENT_ID and NOTION_CLIENT_SECRET from your environment variables:
import { createMCPServer, notionIntegration } from "integrate-sdk/server";
export const { client: serverClient } = createMCPServer({
apiKey: process.env.INTEGRATE_API_KEY,
integrations: [
notionIntegration({
owner: "user", // Optional: 'user' or 'workspace'
}),
],
});You can override the environment variables by passing explicit values:
notionIntegration({
clientId: process.env.CUSTOM_NOTION_ID,
clientSecret: process.env.CUSTOM_NOTION_SECRET,
owner: "user",
});3. Client-Side Usage
The default client automatically includes all integrations. You can use it directly:
import { client } from "integrate-sdk";
await client.authorize("notion");
const results = await client.notion.search({ query: "project" });If you're using a custom client, add the integration to the integrations array:
import { createMCPClient, notionIntegration } from "integrate-sdk";
const customClient = createMCPClient({
integrations: [notionIntegration()],
});Configuration Options
Prop
Type
Available Tools
Pages
notion_search- Search pages and databasesnotion_get_page- Get page content
Examples
Search Pages
const result = await client.notion.search({
query: "meeting notes",
filter: {
property: "object",
value: "page",
},
sort: {
direction: "descending",
timestamp: "last_edited_time",
},
});
console.log("Search results:", result);Get Page
const result = await client.notion.getPage({
pageId: "1234567890abcdef",
});
console.log("Page content:", result);OAuth Configuration
Notion uses a unique OAuth flow that doesn't use traditional scopes. Instead, permissions are configured at the integration level:
owner- Set to'user'(default) for user-level access or'workspace'for workspace-level access
The integration automatically handles Notion's custom OAuth endpoints:
- Authorization:
https://api.notion.com/v1/oauth/authorize - Token:
https://api.notion.com/v1/oauth/token
Sharing Pages with Your Integration
After connecting, users must explicitly share pages or databases with your integration:
- Open a page in Notion
- Click "Share" in the top right
- Invite your integration by name
- Grant appropriate permissions
Error Handling
try {
const result = await client.notion.getPage({
pageId: "1234567890abcdef",
});
} catch (error) {
if (error.message.includes("not found")) {
console.error("Page not found or not shared with integration");
} else if (error.message.includes("authentication")) {
console.error("Authentication failed");
} else {
console.error("Unexpected error:", error);
}
}Next Steps
- Explore the Airtable Integration
- Explore the Linear Integration
- See Advanced Usage for more examples