|
|
@@ -42,7 +42,8 @@ import {
|
|
|
queryQdrantProducts,
|
|
|
queryQdrantOrders,
|
|
|
queryQdrantCustomers,
|
|
|
- queryQdrantCustomContent
|
|
|
+ queryQdrantCustomContent,
|
|
|
+ listCustomContents
|
|
|
} from '../_shared/mcp-qdrant-helpers.ts';
|
|
|
import {
|
|
|
getAccessPolicyConfig,
|
|
|
@@ -219,6 +220,20 @@ const TOOLS: McpTool[] = [
|
|
|
},
|
|
|
required: ['shop_id', 'query']
|
|
|
}
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'woocommerce_list_custom_contents',
|
|
|
+ description: 'List all available custom content (uploaded PDFs and text entries) for a store. Returns titles, types, and status of all custom knowledge base items. Use this to see what custom documentation is available before searching.',
|
|
|
+ inputSchema: {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ shop_id: {
|
|
|
+ type: 'string',
|
|
|
+ description: 'The UUID of the WooCommerce store from the stores table'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ required: ['shop_id']
|
|
|
+ }
|
|
|
}
|
|
|
];
|
|
|
|
|
|
@@ -874,6 +889,50 @@ async function handleSearchCustomContent(args: Record<string, any>): Promise<Too
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Handle list custom contents
|
|
|
+ */
|
|
|
+async function handleListCustomContents(args: Record<string, any>): Promise<ToolCallResult> {
|
|
|
+ const { shop_id } = args;
|
|
|
+
|
|
|
+ try {
|
|
|
+ // List custom content from database
|
|
|
+ const contents = await listCustomContents(shop_id);
|
|
|
+
|
|
|
+ // Filter to only enabled content for display
|
|
|
+ const enabledContents = contents.filter(c => c.isEnabled);
|
|
|
+
|
|
|
+ return {
|
|
|
+ content: [{
|
|
|
+ type: 'text',
|
|
|
+ text: JSON.stringify({
|
|
|
+ total: enabledContents.length,
|
|
|
+ contents: enabledContents.map(c => ({
|
|
|
+ id: c.id,
|
|
|
+ title: c.title,
|
|
|
+ content_type: c.contentType,
|
|
|
+ original_filename: c.originalFilename,
|
|
|
+ page_count: c.pageCount,
|
|
|
+ chunk_count: c.chunkCount,
|
|
|
+ sync_status: c.syncStatus,
|
|
|
+ created_at: c.createdAt
|
|
|
+ }))
|
|
|
+ })
|
|
|
+ }],
|
|
|
+ isError: false
|
|
|
+ };
|
|
|
+ } catch (error: any) {
|
|
|
+ console.error('[MCP WooCommerce] Error listing custom contents:', error);
|
|
|
+ return {
|
|
|
+ content: [{
|
|
|
+ type: 'text',
|
|
|
+ text: JSON.stringify({ error: `Failed to list custom contents: ${error instanceof Error ? error.message : 'Unknown error'}` })
|
|
|
+ }],
|
|
|
+ isError: true
|
|
|
+ };
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Handle tool call
|
|
|
*/
|
|
|
@@ -947,6 +1006,9 @@ async function handleToolCall(params: ToolCallParams): Promise<ToolCallResult> {
|
|
|
}
|
|
|
return await handleSearchCustomContent(args);
|
|
|
|
|
|
+ case 'woocommerce_list_custom_contents':
|
|
|
+ return await handleListCustomContents(args);
|
|
|
+
|
|
|
// Legacy tool names for backward compatibility
|
|
|
case 'woocommerce_list_customers':
|
|
|
return {
|