Skip to main content
Glama

Docflow MCP Server

MCP Server for Docflow — TextIn's document automation platform. Enables LLM agents to classify documents, extract fields/tables/stamps, and run rule-based compliance review through 41 MCP tools.

Features

  • Document classification — auto-classify PDFs, images, Word, and Excel files into user-defined categories

  • Field extraction — extract structured fields, table rows, handwriting, and stamps using LLM/VLM models

  • Compliance review — run AI-powered rule evaluation with risk levels and detailed reasoning

  • Two-layer tool design:

    • 6 workflow tools — high-level composite operations for common pipelines (upload → extract → review)

    • 35 resource tools — one tool per API endpoint for fine-grained configuration and edge cases

Related MCP server: flexorch-mcp

Installation

pip install git+https://github.com/intsig-textin/docflow-mcp.git

Or install in editable mode for development:

git clone https://github.com/intsig-textin/docflow-mcp.git
cd docflow-mcp
pip install -e .

Configuration

Set environment variables before starting the server:

export DOCFLOW_APP_ID=your_app_id
export DOCFLOW_SECRET_CODE=your_secret_code

# Optional: override API host (default: https://docflow.textin.com)
export DOCFLOW_HOST=https://docflow.textin.com

Get your APP_ID and SECRET_CODE from the Docflow console.

Running

Stdio (for MCP clients)

# Via installed command
docflow-mcp

# Or via Python module
python -m docflow_mcp

Claude Code Integration

Add to your Claude Code MCP settings (~/.claude/settings.json or project .claude/settings.json):

{
  "mcpServers": {
    "docflow": {
      "command": "docflow-mcp",
      "env": {
        "DOCFLOW_APP_ID": "your_app_id",
        "DOCFLOW_SECRET_CODE": "your_secret_code"
      }
    }
  }
}

Or if using python -m:

{
  "mcpServers": {
    "docflow": {
      "command": "python",
      "args": ["-m", "docflow_mcp"],
      "env": {
        "DOCFLOW_APP_ID": "your_app_id",
        "DOCFLOW_SECRET_CODE": "your_secret_code"
      }
    }
  }
}

Tool Reference

Workflow Tools (6)

High-level tools that hide polling, multi-step logic, and upload routing.

Tool

Description

docflow_get_or_create_workspace

Find workspace by name, or create if not found (idempotent)

docflow_list_categories

List all enabled categories with field configurations

docflow_create_category

Create category with fields and sample file

docflow_upload_and_extract

Upload files (list or directory) and wait for extraction results

docflow_setup_review_rules

Create review rule repo with groups and rules (idempotent)

docflow_run_review

Submit review task and wait for rule-by-rule results

docflow_upload_and_extract — Upload Routing

Automatically selects upload mode based on file count:

  • ≤ 3 files → synchronous upload (results returned immediately)

  • > 3 files → asynchronous upload + polling until all files complete

Accepts either:

  • file_paths: explicit list of local file paths

  • directory: auto-scans for supported files (PDF, JPG, PNG, DOC, DOCX, XLS, XLSX, OFD, TXT)

docflow_setup_review_rules — Rule Structure

Rule Repository
└── Rule Group (e.g. "金额审核")
    └── Rule (name, prompt, category_ids, risk_level)
        risk_level: 10=high, 20=medium, 30=low

Resource Tools (35)

Thin wrappers covering every CRUD endpoint, organized by resource.

Files

Tool

Endpoint

Description

docflow_fetch_files

GET /file/fetch

Query processed files, filter by status/category

docflow_update_file

POST /file/update

Update file metadata or verification status

docflow_delete_files

POST /file/delete

Permanently delete files by task_id or batch_number

docflow_extract_fields

POST /file/extract_fields

Re-extract specific fields without re-uploading

docflow_retry_files

POST /file/retry

Retry processing for failed files

docflow_amend_category

POST /file/amend_category

Correct misclassified file and trigger re-extraction

Workspaces

Tool

Endpoint

Description

docflow_list_workspaces

GET /workspace/list

List all accessible workspaces

docflow_get_workspace

GET /workspace/get

Get workspace details and statistics

docflow_update_workspace

POST /workspace/update

Update name, description, auth scope, or callback URL

docflow_delete_workspace

POST /workspace/delete

Delete workspace and all contents (permanent)

Categories

Tool

Endpoint

Description

docflow_update_category

POST /category/update

Update category name, model, prompt, or enabled status

docflow_delete_category

POST /category/delete

Delete category (existing file data is preserved)

Category Tables

Tool

Endpoint

Description

docflow_list_category_tables

GET /category/tables/list

List table configs (for extracting structured rows)

docflow_add_category_table

POST /category/tables/add

Add table field group (e.g. invoice line items)

docflow_update_category_table

POST /category/tables/update

Update table name or column definitions

docflow_delete_category_tables

POST /category/tables/delete

Delete table configs

Category Fields

Tool

Endpoint

Description

docflow_list_category_fields

GET /category/fields/list

List fields with field_ids (needed for rule references)

docflow_add_category_fields

POST /category/fields/add

Add fields to existing category

docflow_update_category_field

POST /category/fields/update

Update field name, description, or extraction prompt

docflow_delete_category_fields

POST /category/fields/delete

Delete fields from category

Category Samples

Tool

Endpoint

Description

docflow_add_category_samples

POST /category/sample/upload

Add sample files to improve classification (3–5 recommended)

docflow_list_category_samples

GET /category/sample/list

List all sample files for a category

docflow_delete_category_samples

POST /category/sample/delete

Remove low-quality samples

Review Rule Repositories

Tool

Endpoint

Description

docflow_list_review_repos

GET /review/rule_repo/list

List all rule repositories in workspace

docflow_get_review_repo

GET /review/rule_repo/get

Get repo with all groups and rules

docflow_update_review_repo

POST /review/rule_repo/update

Rename rule repository

docflow_delete_review_repo

POST /review/rule_repo/delete

Delete repo and all its rules (permanent)

Review Rule Groups

Tool

Endpoint

Description

docflow_update_review_rule_group

POST /review/rule_group/update

Rename rule group

docflow_delete_review_rule_group

POST /review/rule_group/delete

Delete group and all its rules

Review Rules

Tool

Endpoint

Description

docflow_update_review_rule

POST /review/rule/update

Update rule prompt, categories, or risk level

docflow_delete_review_rule

POST /review/rule/delete

Delete a single rule

Review Tasks

Tool

Endpoint

Description

docflow_get_review_result

POST /review/task/result

Get current review status without waiting

docflow_delete_review_task

POST /review/task/delete

Delete review tasks

docflow_retry_review_task

POST /review/task/retry

Retry entire review task

docflow_retry_review_rule

POST /review/task/rule/retry

Retry a single rule without re-running others


Typical Workflow

1. docflow_get_or_create_workspace  →  workspace_id
2. docflow_list_categories          →  check existing categories
3. docflow_create_category (×N)     →  category_id per document type
4. docflow_upload_and_extract       →  files[], task_ids[]
5. docflow_setup_review_rules       →  repo_id
6. docflow_run_review               →  status, groups[rule results]

API Coverage

44 of 46 Docflow API endpoints are covered.

Intentionally omitted:

  • GET /auth/token — generates short-lived token for iframe embedding, not agent use

  • GET /category/sample/download — returns binary file content, not useful for agents

Internally called (no separate tool needed):

  • POST /file/upload, /file/upload/sync → used inside docflow_upload_and_extract

  • POST /workspace/create → used inside docflow_get_or_create_workspace

  • POST /review/rule_repo/create, /rule_group/create, /rule/create → used inside docflow_setup_review_rules

  • POST /review/task/submit → used inside docflow_run_review

Requirements

  • Python ≥ 3.10

  • Network access to docflow.textin.com

  • Docflow account with valid APP_ID and SECRET_CODE

License

MIT

Available Tools

41 tools
docflow_add_category_fieldsDocflow Add Category FieldsC

Add fields to an existing category (POST /category/fields/add).

Inputs: fields (required), category_id (required), workspace_id (required). Returns: object

docflow_add_category_samplesDocflow Add Category SamplesA

Add sample files to a category to improve classification accuracy (POST /category/sample/upload).

More samples (3–5 recommended, max 10 total) improve classification reliability.

Inputs: category_id (required), workspace_id (required), sample_file_paths (required). Returns: object

docflow_add_category_tableDocflow Add Category TableA

Add a table field group to a category (POST /category/tables/add).

Use for extracting structured table data (e.g. invoice line items, hotel charges).

Inputs: name (required), fields (required), category_id (required), workspace_id (required). Returns: object

docflow_amend_categoryDocflow Amend CategoryA

Correct a misclassified file's category and trigger re-extraction (POST /file/amend_category).

Use when a file was classified into the wrong category. The file will be re-processed using the correct category's field configuration.

Inputs: task_id (required), category (required), workspace_id (required). Returns: object

docflow_create_categoryDocflow Create CategoryB

Create a file category with field configuration and a sample file.

Inputs: name (required), fields (required), workspace_id (required), sample_file_path (required), +2 more. Returns: object

docflow_delete_categoryDocflow Delete CategoryA

Delete a file category and its field configuration (POST /category/delete). WARNING: Existing files classified under this category retain their extracted data, but future uploads will not match this category.

Inputs: category_id (required), workspace_id (required). Returns: object

docflow_delete_category_fieldsDocflow Delete Category FieldsB

Delete fields from a category (POST /category/fields/delete).

Inputs: field_ids (required), category_id (required), workspace_id (required). Returns: object

docflow_delete_category_samplesDocflow Delete Category SamplesA

Delete sample files from a category (POST /category/sample/delete). Use to remove low-quality or irrelevant samples that hurt classification accuracy.

Inputs: sample_ids (required), category_id (required), workspace_id (required). Returns: object

docflow_delete_category_tablesDocflow Delete Category TablesC

Delete table configurations from a category (POST /category/tables/delete).

Inputs: table_ids (required), category_id (required), workspace_id (required). Returns: object

docflow_delete_filesDocflow Delete FilesA

Delete processed files from a workspace (POST /file/delete). Provide either task_ids or batch_numbers. Deletion is permanent.

Inputs: workspace_id (required), task_ids, batch_numbers. Returns: object

docflow_delete_review_repoDocflow Delete Review RepoA

Delete a review rule repository and all its groups and rules (POST /review/rule_repo/delete). WARNING: This is permanent. Existing review task results are not affected.

Inputs: repo_id (required), workspace_id (required). Returns: object

docflow_delete_review_ruleDocflow Delete Review RuleC

Delete a review rule (POST /review/rule/delete).

Inputs: rule_id (required), workspace_id (required). Returns: object

docflow_delete_review_rule_groupDocflow Delete Review Rule GroupA

Delete a review rule group and all rules within it (POST /review/rule_group/delete).

Inputs: group_id (required), workspace_id (required). Returns: object

docflow_delete_review_taskDocflow Delete Review TaskC

Delete review tasks (POST /review/task/delete).

Inputs: task_ids (required), workspace_id (required). Returns: object

docflow_delete_workspaceDocflow Delete WorkspaceA

Delete a workspace and all its contents (POST /workspace/delete). WARNING: This permanently deletes all files, categories, and review rules in the workspace.

Inputs: workspace_id (required). Returns: object

docflow_extract_fieldsDocflow Extract FieldsA

Re-extract specific fields from an already-processed file (POST /file/extract_fields).

Use when you need to extract additional fields without re-uploading the file, or when the original extraction missed certain fields.

Inputs: task_id (required), workspace_id (required), fields, tables. Returns: object

docflow_fetch_filesDocflow Fetch FilesA

Query processed files in a workspace (GET /file/fetch).

Useful for checking status of previously uploaded files or retrieving results later. recognition_status: "0"=pending, "1"=success, "2"=failed, "3"=processing.

Inputs: workspace_id (required), page, file_id, category, +3 more. Returns: object

docflow_get_or_create_workspaceDocflow Get Or Create WorkspaceA

Find a workspace by name, or create one if it does not exist.

Returns: workspace_id (str): ID of the workspace. created (bool): True if a new workspace was created.

Use this as Step 1 of every workflow to ensure a workspace is ready.

Inputs: name (required), description, enterprise_id. Returns: object

docflow_get_review_repoDocflow Get Review RepoA

Get a review rule repository with all its groups and rules (GET /review/rule_repo/get). Use this to inspect existing rule configurations before making changes.

Inputs: repo_id (required), workspace_id (required). Returns: object

docflow_get_review_resultDocflow Get Review ResultA

Get the current result of a review task without waiting (POST /review/task/result).

Use to check status of a previously submitted review, or for manual polling. status: 0=pending, 1=pass, 2=failed, 3=reviewing, 4=not_pass, 7=recognition_failed.

Inputs: task_id (required), workspace_id (required). Returns: object

docflow_get_workspaceDocflow Get WorkspaceB

Get detailed information about a specific workspace (GET /workspace/get). Returns workspace metadata including name, description, auth_scope, and statistics.

Inputs: workspace_id (required). Returns: object

docflow_list_categoriesDocflow List CategoriesA

List all enabled categories in a workspace, including their field configurations.

Returns a list of category objects with name, category_id, and fields. Use this to check which categories are already configured before creating new ones.

Inputs: workspace_id (required). Returns: result

docflow_list_category_fieldsDocflow List Category FieldsA

List all fields configured in a category (GET /category/fields/list).

Returns field_id, name, description, and configuration for each field. Use this to get field_ids needed when building review rules with referenced_fields.

Inputs: category_id (required), workspace_id (required). Returns: result

docflow_list_category_samplesDocflow List Category SamplesA

List all sample files configured for a category (GET /category/sample/list). Returns sample_id, file name, and upload time for each sample.

Inputs: category_id (required), workspace_id (required). Returns: result

docflow_list_category_tablesDocflow List Category TablesA

List all table configurations in a category (GET /category/tables/list).

Returns table_id, name, and fields for each table. Use this to get table_id before adding table fields or building review rules.

Inputs: category_id (required), workspace_id (required). Returns: result

docflow_list_review_reposDocflow List Review ReposA

List all review rule repositories in a workspace (GET /review/rule_repo/list). Returns repo_id, name, and creation time for each.

Inputs: workspace_id (required). Returns: result

docflow_list_workspacesDocflow List WorkspacesA

List all workspaces accessible to the current account (GET /workspace/list). Returns workspace_id, name, description, and auth_scope for each.

Inputs: enterprise_id. Returns: result

docflow_retry_filesDocflow Retry FilesA

Retry processing for files that failed (POST /file/retry). Use when recognition_status=2 (failed).

Inputs: task_ids (required), workspace_id (required). Returns: object

docflow_retry_review_ruleDocflow Retry Review RuleA

Retry evaluation of a single rule within a review task (POST /review/task/rule/retry).

Use when one specific rule failed or needs re-evaluation after updating its prompt, without re-running all other rules in the task.

Inputs: rule_id (required), task_id (required), workspace_id (required). Returns: object

docflow_retry_review_taskDocflow Retry Review TaskA

Retry an entire review task that failed or produced unexpected results (POST /review/task/retry). All rules in the task will be re-evaluated.

Inputs: task_id (required), workspace_id (required). Returns: object

docflow_run_reviewDocflow Run ReviewA

Submit a review task and wait for results.

Inputs: repo_id (required), task_ids (required), workspace_id (required), name, +1 more. Returns: object

docflow_setup_review_rulesDocflow Setup Review RulesB

Create a review rule repository (idempotent — reuses existing repo if name matches).

Inputs: repo_name (required), rule_groups (required), workspace_id (required). Returns: object

docflow_update_categoryDocflow Update CategoryC

Update an existing file category's settings (POST /category/update).

Inputs: category_id (required), workspace_id (required), name, enabled, +2 more. Returns: object

docflow_update_category_fieldDocflow Update Category FieldA

Update a field's name, description, or extraction prompt (POST /category/fields/update).

Updating the prompt can improve extraction accuracy for specific field types.

Inputs: field_id (required), category_id (required), workspace_id (required), name, +2 more. Returns: object

docflow_update_category_tableDocflow Update Category TableC

Update a table configuration in a category (POST /category/tables/update).

Inputs: table_id (required), category_id (required), workspace_id (required), name, +1 more. Returns: object

docflow_update_fileDocflow Update FileB

Update metadata or verification status of a processed file (POST /file/update).

Inputs: data (required), file_id (required), workspace_id (required). Returns: object

docflow_update_review_repoDocflow Update Review RepoC

Rename a review rule repository (POST /review/rule_repo/update).

Inputs: name (required), repo_id (required), workspace_id (required). Returns: object

docflow_update_review_ruleDocflow Update Review RuleB

Update an existing review rule's prompt or configuration (POST /review/rule/update).

Use to refine rule prompts based on review results, or adjust risk levels. risk_level: 10=high, 20=medium, 30=low.

Inputs: rule_id (required), workspace_id (required), name, prompt, +3 more. Returns: object

docflow_update_review_rule_groupDocflow Update Review Rule GroupB

Rename a review rule group (POST /review/rule_group/update).

Inputs: name (required), group_id (required), workspace_id (required). Returns: object

docflow_update_workspaceDocflow Update WorkspaceB

Update workspace settings (POST /workspace/update).

Inputs: workspace_id (required), name, auth_scope, description, +1 more. Returns: object

docflow_upload_and_extractDocflow Upload And ExtractA

Upload files and wait for classification and extraction to complete.

Provide either file_paths (explicit list) or directory (auto-scans supported files). Supported formats: PDF, JPG, PNG, DOC, DOCX, XLS, XLSX, OFD, TXT.

Inputs: workspace_id (required), timeout, category, directory, +2 more. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

    TDQS

    B3/5.0

    Scored across 41 tools

    Disambiguation4/5

    Each tool targets a distinct resource/action such as workspace, category, field, table, sample, review repo/rule/task, or file, so descriptions mostly prevent ambiguity. Some close pairs like retry_review_rule vs retry_review_task or update_category vs update_category_field require careful reading, but the boundaries are clear enough.

    Naming Consistency4/5

    All tools share the docflow_ snake_case prefix and generally follow a verb-first naming pattern, making the set predictable. Minor inconsistencies like delete_category_tables vs add_category_table, or the less explicit upload_and_extract, prevent a perfect score.

    Tool Count2/5

    41 tools is well above the 25+ threshold and feels too heavy for an agent to efficiently select from, even though the domain is broad. Many tools are narrow API endpoints for closely related subresources that could potentially be consolidated.

    Completeness3/5

    File and category coverage is fairly complete with create/read/update/delete operations, but review-rule management has a notable gap: there is no explicit way to add a new rule or rule group to an existing repository, only update/delete and whole-repo setup. There is also no list-review-tasks operation, which creates partial dead ends in review workflows.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers