query_content
Search and filter Drupal content by type, title, or publication status to find specific nodes in your Drupal site.
Instructions
Search and filter Drupal content by type. Returns a list of nodes matching the criteria.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contentType | Yes | The machine name of the content type (e.g., "article", "page", "blog_post") | |
| limit | No | Maximum number of results to return (default: 10) | |
| title | No | Filter by title (partial match) | |
| status | No | Filter by publication status (true = published, false = unpublished) |
Implementation Reference
- src/drupal-client.ts:39-76 (handler)The handler function that executes the query_content tool logic by fetching content from Drupal's JSON:API.
async queryContent( contentType: string, options: { limit?: number | undefined; title?: string | undefined; status?: boolean | undefined; } = {} ): Promise<DrupalNode[]> { try { // Build query parameters for JSON:API const params: any = { 'page[limit]': options.limit || 10, }; // Add filters if provided const filters: string[] = []; if (options.title) { params['filter[title][operator]'] = 'CONTAINS'; params['filter[title][value]'] = options.title; } if (options.status !== undefined) { params['filter[status]'] = options.status ? '1' : '0'; } // Make the request to JSON:API const response = await this.client.get<JsonApiResponse>( `/node/${contentType}`, { params } ); // Return array of nodes (handle both single and multiple results) return Array.isArray(response.data.data) ? response.data.data : [response.data.data]; } catch (error: any) { throw new Error(`Failed to query content: ${error.message}`); } }