Method

importMap.list

List Import map entries (Bayesian, desc, memo, csv-account-map) and online entries.

Lists what the importers have learned: the entries in the book that propose a transfer account for an imported transaction. They are the bayes tokens GnuCash's Bayesian matcher trains, the plain desc and memo maps, the csvAccountMap of account names in CSV files, and the online IDs of bank connections (onlineId, hbci, ofxIncomeAccount). Each says which account holds it, its key, the account it points to and whether it is still valid.

An entry is invalid when the account it points to no longer exists; invalidOnly lists what importMap.delete with invalid would remove. A book that has never imported has none.

Examples

A book whose checking account has learned from a few imports. GnuCash's Bayesian matcher keeps one entry per token and account (the words of a description, and the day of the week), the plain maps one per description or memo, and the CSV map one per account name in a file. The Coffee token points to an account deleted since, so it is invalid:

Example: with a copy of the synthetic/import-map example book open as book.gnucash.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"importMap.list","params":{}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "entries": [
      {
        "account": {
          "guid": "…",
          "fullName": "Assets:Checking"
        },
        "kind": "bayes",
        "key": "ACME",
        "target": {
          "guid": "…",
          "fullName": "Income:Salary"
        },
        "count": 1,
        "valid": true
      },
      {
        "kind": "bayes",
        "key": "Coffee",
        "target": null,
        "valid": false,
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Corner",
        "target": {
          "guid": "…",
          "fullName": "Expenses:Groceries"
        },
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Friday",
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Grocer",
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Monday",
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Salary",
        "…": "…"
      },
      {
        "kind": "desc",
        "key": "Corner Grocer",
        "target": {
          "guid": "…",
          "fullName": "Expenses:Groceries"
        },
        "…": "…"
      },
      {
        "kind": "memo",
        "key": "March rent",
        "target": {
          "guid": "…",
          "fullName": "Expenses:Rent"
        },
        "…": "…"
      },
      {
        "kind": "csvAccountMap",
        "key": "CHK-001",
        "target": {
          "guid": "…",
          "fullName": "Assets:Checking"
        },
        "…": "…"
      }
    ]
  }
}

Request:

{"jsonrpc":"2.0","id":2,"method":"importMap.list","params":{"invalidOnly":true}}

Response:

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "entries": [
      {
        "account": {
          "guid": "…",
          "fullName": "Assets:Checking"
        },
        "kind": "bayes",
        "key": "Coffee",
        "target": null,
        "count": 1,
        "valid": false
      }
    ]
  }
}

Command line

red-ale exec --book book.gnucash --script - <<'EOF'
importMap.list {}
importMap.list {"invalidOnly":true}
EOF

It prints:

[
  {
    "entries": [
      {
        "account": {
          "guid": "…",
          "fullName": "Assets:Checking"
        },
        "kind": "bayes",
        "key": "ACME",
        "target": {
          "guid": "…",
          "fullName": "Income:Salary"
        },
        "count": 1,
        "valid": true
      },
      {
        "kind": "bayes",
        "key": "Coffee",
        "target": null,
        "valid": false,
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Corner",
        "target": {
          "guid": "…",
          "fullName": "Expenses:Groceries"
        },
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Friday",
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Grocer",
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Monday",
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Salary",
        "…": "…"
      },
      {
        "kind": "desc",
        "key": "Corner Grocer",
        "target": {
          "guid": "…",
          "fullName": "Expenses:Groceries"
        },
        "…": "…"
      },
      {
        "kind": "memo",
        "key": "March rent",
        "target": {
          "guid": "…",
          "fullName": "Expenses:Rent"
        },
        "…": "…"
      },
      {
        "kind": "csvAccountMap",
        "key": "CHK-001",
        "target": {
          "guid": "…",
          "fullName": "Assets:Checking"
        },
        "…": "…"
      }
    ]
  },
  {
    "entries": [
      {
        "account": {
          "guid": "…",
          "fullName": "Assets:Checking"
        },
        "kind": "bayes",
        "key": "Coffee",
        "target": null,
        "count": 1,
        "valid": false
      }
    ]
  }
]

MCP tool call

Tool call:

{"name":"importMap.list","arguments":{}}

Result:

{
  "structuredContent": {
    "entries": [
      {
        "account": {
          "guid": "…",
          "fullName": "Assets:Checking"
        },
        "kind": "bayes",
        "key": "ACME",
        "target": {
          "guid": "…",
          "fullName": "Income:Salary"
        },
        "count": 1,
        "valid": true
      },
      {
        "kind": "bayes",
        "key": "Coffee",
        "target": null,
        "valid": false,
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Corner",
        "target": {
          "guid": "…",
          "fullName": "Expenses:Groceries"
        },
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Friday",
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Grocer",
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Monday",
        "…": "…"
      },
      {
        "kind": "bayes",
        "key": "Salary",
        "…": "…"
      },
      {
        "kind": "desc",
        "key": "Corner Grocer",
        "target": {
          "guid": "…",
          "fullName": "Expenses:Groceries"
        },
        "…": "…"
      },
      {
        "kind": "memo",
        "key": "March rent",
        "target": {
          "guid": "…",
          "fullName": "Expenses:Rent"
        },
        "…": "…"
      },
      {
        "kind": "csvAccountMap",
        "key": "CHK-001",
        "target": {
          "guid": "…",
          "fullName": "Assets:Checking"
        },
        "…": "…"
      }
    ]
  }
}

Tool call:

{"name":"importMap.list","arguments":{"invalidOnly":true}}

Result:

{
  "structuredContent": {
    "entries": [
      {
        "account": {
          "guid": "…",
          "fullName": "Assets:Checking"
        },
        "kind": "bayes",
        "key": "Coffee",
        "target": null,
        "count": 1,
        "valid": false
      }
    ]
  }
}

A book that has never imported has none:

Example: with a copy of the synthetic/rich example book open as book.gnucash.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"importMap.list","params":{}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "entries": []
  }
}

Command line

red-ale exec --book book.gnucash importMap.list

It prints:

{
  "entries": []
}

MCP tool call

Tool call:

{"name":"importMap.list","arguments":{}}

Result:

{
  "structuredContent": {
    "entries": []
  }
}

Effect: read.

Params

Params of importMap.list.

  • account (AccountRef or null): Only the entries this account holds (for csvAccountMap, the target, which holds it).
  • kind (KindWire or null): Only this kind.
  • invalidOnly (boolean): Only the entries the editor's "Delete invalid mappings" would remove.

Result

The entries.

  • entries (array of ImportMapEntry, required): By holding account's full name, then kind, then key, bytewise.