@answerai/answeragent-mcp 1.0.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -129,12 +129,62 @@ The server requires two environment variables:
129
129
  ### Document Store Management
130
130
  - `create_document_store` - Create document stores
131
131
  - `get_document_store` - Get store details
132
+ - `update_document_store` - Update document stores
132
133
  - `delete_document_store` - Remove document stores
133
134
  - `list_document_stores` - List all stores
134
- - `query_vector_store` - Query document stores
135
+ - `query_vector_store` - Query document stores (basic)
136
+ - `query_vector_store_with_filter` - Query with metadata filtering (see below)
135
137
  - `upsert_document` - Add/update documents
136
138
  - `refresh_document_store` - Refresh store contents
137
139
 
140
+ #### Metadata Filtering with `query_vector_store_with_filter`
141
+
142
+ This tool allows semantic search with Pinecone metadata filters to narrow down results based on document metadata fields.
143
+
144
+ **Parameters:**
145
+ - `storeId` (required): Document store ID
146
+ - `query` (required): Semantic search query text
147
+ - `metadataFilter` (optional): Pinecone metadata filter object
148
+
149
+ **Supported Filter Operators:**
150
+
151
+ | Operator | Description | Example |
152
+ |----------|-------------|---------|
153
+ | `$eq` | Equal to | `{"department": {"$eq": "sales"}}` |
154
+ | `$ne` | Not equal to | `{"status": {"$ne": "archived"}}` |
155
+ | `$gt` | Greater than (numbers) | `{"version": {"$gt": 1.0}}` |
156
+ | `$gte` | Greater than or equal | `{"version": {"$gte": 2.0}}` |
157
+ | `$lt` | Less than (numbers) | `{"priority": {"$lt": 5}}` |
158
+ | `$lte` | Less than or equal | `{"priority": {"$lte": 3}}` |
159
+ | `$in` | Value in array | `{"status": {"$in": ["active", "pending"]}}` |
160
+ | `$nin` | Value not in array | `{"status": {"$nin": ["deleted", "archived"]}}` |
161
+ | `$or` | Any condition matches | `{"$or": [{"dept": {"$eq": "sales"}}, {"dept": {"$eq": "marketing"}}]}` |
162
+ | `$and` | All conditions match | `{"$and": [{"category": {"$eq": "docs"}}, {"version": {"$gte": 2.0}}]}` |
163
+
164
+ **Example Filters:**
165
+
166
+ ```json
167
+ // Simple equality
168
+ {"department": {"$eq": "engineering"}}
169
+
170
+ // Numeric comparison
171
+ {"version": {"$gte": 2.0}}
172
+
173
+ // Multiple conditions (implicit AND)
174
+ {"department": {"$eq": "sales"}, "product": {"$eq": "enterprise"}}
175
+
176
+ // OR condition
177
+ {"$or": [{"department": {"$eq": "sales"}}, {"department": {"$eq": "marketing"}}]}
178
+
179
+ // IN operator
180
+ {"department": {"$in": ["sales", "marketing", "support"]}}
181
+ ```
182
+
183
+ **Important Notes:**
184
+ - String comparisons are case-sensitive
185
+ - Numeric operators require numeric values in metadata (not strings)
186
+ - Documents must have metadata fields set during upsert to be filterable
187
+
138
188
  ### Assistant Management
139
189
  - `create_assistant` - Create AI assistants
140
190
  - `get_assistant` - Get assistant details
@@ -199,6 +249,18 @@ After configuring in Cursor, you can use natural language commands:
199
249
  4. **Query documents**:
200
250
  > "Search my 'Contracts' document store for information about payment terms"
201
251
 
252
+ 5. **Query with metadata filter**:
253
+ > "Search my document store for pricing information, but only from the sales department"
254
+
255
+ The agent will use `query_vector_store_with_filter` with:
256
+ ```json
257
+ {
258
+ "storeId": "your-store-id",
259
+ "query": "pricing information",
260
+ "metadataFilter": {"department": {"$eq": "sales"}}
261
+ }
262
+ ```
263
+
202
264
  ### With Claude Desktop
203
265
 
204
266
  After adding to your Claude Desktop configuration:
@@ -38,4 +38,39 @@ export class DocumentStoreService {
38
38
  const { data } = await apiClient.post(`/document-store/vectorstore/query`, payload);
39
39
  return data;
40
40
  }
41
+ /**
42
+ * Query vector store with metadata filtering support.
43
+ *
44
+ * This method allows semantic search with Pinecone metadata filters
45
+ * to narrow down results based on document metadata fields.
46
+ *
47
+ * @param payload - Query parameters
48
+ * @param payload.storeId - Document store ID
49
+ * @param payload.query - Semantic search query text
50
+ * @param payload.metadataFilter - Optional Pinecone metadata filter object
51
+ *
52
+ * @returns Query results with matching documents, metadata, and timing info
53
+ *
54
+ * @example
55
+ * // Query with department filter
56
+ * await queryVectorStoreWithFilter({
57
+ * storeId: "abc-123",
58
+ * query: "What are the pricing options?",
59
+ * metadataFilter: { department: { $eq: "sales" } }
60
+ * });
61
+ */
62
+ async queryVectorStoreWithFilter(payload) {
63
+ const requestBody = {
64
+ storeId: payload.storeId,
65
+ query: payload.query,
66
+ };
67
+ // Pass metadata filter via inputs (merged with vectorStoreConfig on server)
68
+ if (payload.metadataFilter) {
69
+ requestBody.inputs = {
70
+ pineconeMetadataFilter: payload.metadataFilter,
71
+ };
72
+ }
73
+ const { data } = await apiClient.post(`/document-store/vectorstore/query`, requestBody);
74
+ return data;
75
+ }
41
76
  }
@@ -101,7 +101,7 @@ export const refreshDocumentStore = {
101
101
  };
102
102
  export const queryVectorStore = {
103
103
  name: "query_vector_store",
104
- description: "Query vector store",
104
+ description: "Query vector store (basic, no filtering)",
105
105
  inputSchema: {
106
106
  type: "object",
107
107
  properties: {
@@ -115,3 +115,102 @@ export const queryVectorStore = {
115
115
  return { content: [{ type: "text", text: JSON.stringify(result) }] };
116
116
  },
117
117
  };
118
+ /**
119
+ * Query vector store with metadata filtering.
120
+ *
121
+ * This tool allows semantic search with Pinecone metadata filters to narrow down
122
+ * results based on document metadata fields. Documents must have metadata fields
123
+ * set during upsert to be filterable.
124
+ *
125
+ * ## Metadata Filter Syntax (Pinecone)
126
+ *
127
+ * The metadataFilter parameter accepts a JSON object with Pinecone filter operators.
128
+ *
129
+ * ### Comparison Operators:
130
+ * - `$eq` - Equal to (string, number, boolean)
131
+ * - `$ne` - Not equal to
132
+ * - `$gt` - Greater than (numbers only)
133
+ * - `$gte` - Greater than or equal to (numbers only)
134
+ * - `$lt` - Less than (numbers only)
135
+ * - `$lte` - Less than or equal to (numbers only)
136
+ * - `$in` - Value is in array
137
+ * - `$nin` - Value is not in array
138
+ *
139
+ * ### Logical Operators:
140
+ * - `$and` - All conditions must match
141
+ * - `$or` - Any condition must match
142
+ *
143
+ * ### Example Filters:
144
+ *
145
+ * 1. Simple equality:
146
+ * { "department": { "$eq": "sales" } }
147
+ *
148
+ * 2. Numeric comparison:
149
+ * { "version": { "$gte": 2.0 } }
150
+ *
151
+ * 3. Multiple conditions (AND - implicit):
152
+ * { "department": { "$eq": "sales" }, "product": { "$eq": "enterprise" } }
153
+ *
154
+ * 4. OR condition:
155
+ * { "$or": [{ "department": { "$eq": "sales" } }, { "department": { "$eq": "marketing" } }] }
156
+ *
157
+ * 5. AND with OR:
158
+ * { "$and": [{ "category": { "$eq": "documentation" } }, { "$or": [{ "version": { "$gte": 2.0 } }, { "priority": { "$eq": "high" } }] }] }
159
+ *
160
+ * 6. IN operator (value in list):
161
+ * { "department": { "$in": ["sales", "marketing", "support"] } }
162
+ *
163
+ * 7. NOT IN operator:
164
+ * { "status": { "$nin": ["archived", "deleted"] } }
165
+ *
166
+ * ### Important Notes:
167
+ * - String comparisons are case-sensitive
168
+ * - Numeric operators ($gt, $gte, $lt, $lte) require numeric values in metadata
169
+ * - Security filters (_chatflowId, _organizationId) are automatically applied
170
+ * - Filter fields must exist in document metadata to match
171
+ */
172
+ export const queryVectorStoreWithFilter = {
173
+ name: "query_vector_store_with_filter",
174
+ description: `Query vector store with metadata filtering. Allows semantic search filtered by document metadata.
175
+
176
+ METADATA FILTER OPERATORS:
177
+ - $eq: Equal to (e.g., {"department": {"$eq": "sales"}})
178
+ - $ne: Not equal to
179
+ - $gt, $gte, $lt, $lte: Numeric comparisons (e.g., {"version": {"$gte": 2.0}})
180
+ - $in: Value in array (e.g., {"status": {"$in": ["active", "pending"]}})
181
+ - $nin: Value not in array
182
+ - $or: Any condition matches (e.g., {"$or": [{"dept": {"$eq": "sales"}}, {"dept": {"$eq": "marketing"}}]})
183
+ - $and: All conditions match
184
+
185
+ EXAMPLES:
186
+ 1. Filter by department: {"department": {"$eq": "engineering"}}
187
+ 2. Filter by version >= 2.0: {"version": {"$gte": 2.0}}
188
+ 3. Multiple departments: {"$or": [{"department": {"$eq": "sales"}}, {"department": {"$eq": "marketing"}}]}
189
+ 4. Combined filters: {"category": {"$eq": "docs"}, "version": {"$gte": 1.5}}`,
190
+ inputSchema: {
191
+ type: "object",
192
+ properties: {
193
+ storeId: {
194
+ type: "string",
195
+ description: "Document store ID (UUID)",
196
+ },
197
+ query: {
198
+ type: "string",
199
+ description: "Semantic search query text",
200
+ },
201
+ metadataFilter: {
202
+ type: "object",
203
+ description: "Pinecone metadata filter object. Use operators like $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $or, $and",
204
+ },
205
+ },
206
+ required: ["storeId", "query"],
207
+ },
208
+ handler: async ({ storeId, query, metadataFilter, }) => {
209
+ const result = await service.queryVectorStoreWithFilter({
210
+ storeId,
211
+ query,
212
+ metadataFilter,
213
+ });
214
+ return { content: [{ type: "text", text: JSON.stringify(result) }] };
215
+ },
216
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@answerai/answeragent-mcp",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "A lightweight Model Context Protocol (MCP) server for Answer AI chatflow and document store management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",