# Search — Notion

> Search Notion for pages and databases (data sources) by title. Use this first to resolve a page or database name into an ID that the other Notion tools require (e.g. Query Data Source, Retrieve Database Schema, Get Page, Create Page)…

- Key: `notion-search`
- Type: Action (Read-only)
- Version: 1.0.1
- App: Notion (`notion`) — https://pipedream.com/apps/notion.md
- This page (HTML): https://pipedream.com/apps/notion/actions/search
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/notion/actions/search/search.mjs

## Description

Search Notion for pages and databases (data sources) by title. **Use this first to resolve a page or database name into an ID** that the other Notion tools require (e.g. **Query Data Source**, **Retrieve Database Schema**, **Get Page**, **Create Page**). Leave `query` blank to list everything the integration can access. Set `filter` to `data_source` to find databases or `page` to find pages — on the current Notion API a database is returned as a `data_source` object, and its `id` is the **data source ID** you pass to the database tools. [See the documentation](https://developers.notion.com/reference/post-search)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `query` | `string` | No | Text to match against page and data source titles. Leave blank to return all accessible objects. |
| `filter` | `string` | No | Restrict results to page or data_source (database). Omit to return both. |
| `pageSize` | `integer` | No | The number of items from the full list desired in the response (max 100) |
| `startCursor` | `string` | No | Pagination cursor from a previous response's next_cursor. Omit for the first page. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "notion",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "notion-search",
  arguments: {
    query: "Query",
    filter: "Object Type",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "notion-search",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    notion: { authProvisionId: "apn_xxxxxxx" },
    query: "Query",
    filter: "Object Type",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "notion-search",
    "configured_props": {
      "notion": { "authProvisionId": "apn_xxxxxxx" },
      "query": "Query",
      "filter": "Object Type"
    }
  }'
```

---

- App: https://pipedream.com/apps/notion.md · All apps: https://pipedream.com/apps
