Skip to content
← Public packages

@kody/doordash

Order food on DoorDash as a customer through the consumer MCP used by dd-cli.

src/search.ts

30 lines · 920 B · TypeScript
/**
 * Search nearby restaurants (`doordash_find_restaurants`).
 *
 * ```ts
 * import search from 'kody:@kody/doordash/search'
 * await search({ query: 'sushi near me', addressId: '…' })
 * ```
 */

import { callMcpTool, TOOLS, type DoorDashMcpAuthInput } from './mcp.ts'

export type SearchInput = DoorDashMcpAuthInput & {
	query: string
	lat?: number
	lng?: number
	addressId?: string
	limit?: number
	dryRun?: boolean
}

export default async function search(input: SearchInput) {
	const query = String(input.query ?? '').trim()
	if (!query) throw new Error('query is required.')
	const args: Record<string, unknown> = { query }
	if (input.addressId) args.address_id = String(input.addressId)
	if (input.lat != null) args.lat = input.lat
	if (input.lng != null) args.lng = input.lng
	if (input.limit != null) args.limit = input.limit
	return callMcpTool({ ...input, name: TOOLS.findRestaurants, arguments: args })
}