Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/notion-mcp

src/search.ts

22 lines · 471 B · TypeScript
import { notionMcpSetupMessage, callNotionMcp, firstArray } from './mcp.ts'

type Input = { query?: string }

export default async function searchNotion(input: Input = {}) {
	const mcp = await callNotionMcp(
		[
  "search",
  "notion-search",
  "API-post-search"
],
		{ query: input.query?.trim() || undefined },
	)
	if (!mcp) {
		throw new Error(notionMcpSetupMessage())
	}
	return {
		via: 'mcp',
		tool: mcp.tool,
		results: firstArray(mcp.result) ?? mcp.result,
	}
}