Add document filters to MCP and n8n APIs

Align MCP and n8n document listing endpoints with the GraphQL console
API so every document filter is available across all three interfaces.

MCP:
- listDocuments: add status filter, default to ACTIVE
- listDocumentVersions: add statuses filter
- DocumentOrderField: add UPDATED_AT

n8n:
- document getAll: add query, documentTypes, classifications, status filters (default ACTIVE)
- document getAllVersions: add statuses filter
- document getAllSignatures: add states and activeContract filters

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-04-15 11:07:57 +02:00
parent ef86a6bf60
commit 891bc02f3e
5 changed files with 190 additions and 13 deletions

View File

@@ -60,6 +60,70 @@ export const description: INodeProperties[] = [
default: 50,
description: 'Max number of results to return',
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
placeholder: 'Add Filter',
default: {},
displayOptions: {
show: {
resource: ['document'],
operation: ['getAll'],
},
},
options: [
{
displayName: 'Query',
name: 'query',
type: 'string',
default: '',
description: 'Search query to filter documents',
},
{
displayName: 'Document Types',
name: 'documentTypes',
type: 'multiOptions',
default: [],
description: 'Filter by document type',
options: [
{ name: 'Governance', value: 'GOVERNANCE' },
{ name: 'Other', value: 'OTHER' },
{ name: 'Plan', value: 'PLAN' },
{ name: 'Policy', value: 'POLICY' },
{ name: 'Procedure', value: 'PROCEDURE' },
{ name: 'Record', value: 'RECORD' },
{ name: 'Register', value: 'REGISTER' },
{ name: 'Report', value: 'REPORT' },
{ name: 'Template', value: 'TEMPLATE' },
],
},
{
displayName: 'Classifications',
name: 'classifications',
type: 'multiOptions',
default: [],
description: 'Filter by document classification',
options: [
{ name: 'Confidential', value: 'CONFIDENTIAL' },
{ name: 'Internal', value: 'INTERNAL' },
{ name: 'Public', value: 'PUBLIC' },
{ name: 'Secret', value: 'SECRET' },
],
},
{
displayName: 'Status',
name: 'status',
type: 'multiOptions',
default: [],
description: 'Filter by document status',
options: [
{ name: 'Active', value: 'ACTIVE' },
{ name: 'Archived', value: 'ARCHIVED' },
],
},
],
},
];
export async function execute(
@@ -69,12 +133,19 @@ export async function execute(
const organizationId = this.getNodeParameter('organizationId', itemIndex) as string;
const returnAll = this.getNodeParameter('returnAll', itemIndex) as boolean;
const limit = this.getNodeParameter('limit', itemIndex, 50) as number;
const filters = this.getNodeParameter('filters', itemIndex, {}) as IDataObject;
const filter: IDataObject = {};
if (filters.query) filter.query = filters.query;
if ((filters.documentTypes as string[])?.length) filter.documentTypes = filters.documentTypes;
if ((filters.classifications as string[])?.length) filter.classifications = filters.classifications;
filter.status = (filters.status as string[])?.length ? filters.status : ['ACTIVE'];
const query = `
query GetDocuments($organizationId: ID!, $first: Int, $after: CursorKey) {
query GetDocuments($organizationId: ID!, $first: Int, $after: CursorKey, $filter: DocumentFilter) {
node(id: $organizationId) {
... on Organization {
documents(first: $first, after: $after) {
documents(first: $first, after: $after, filter: $filter) {
edges {
node {
id
@@ -97,10 +168,12 @@ export async function execute(
}
`;
const variables: IDataObject = { organizationId, filter };
const documents = await proboApiRequestAllItems.call(
this,
query,
{ organizationId },
variables,
(response) => {
const data = response?.data as IDataObject | undefined;
const node = data?.node as IDataObject | undefined;