Skip to content

MCP (Model Context Protocol)

Model Context Protocol (MCP) is an open protocol developed by Anthropic that enables AI models to securely connect to external data sources and tools. It provides a standardized way for AI tools to access information and perform actions while maintaining security and user control.

With the MCP protocol, you can use your preferred AI tools to add transactions (e.g. create transactions using natural language or import multiple transactions from different formats), query transaction data (e.g. use your AI tools to analyze historical transaction records), and more.

Note: When using a third-party large language model service, be cautious with the MCP feature, because your private data may be sent to the third-party provider.

Configuration

By default, ezBookkeeping does not enable the MCP server. You can enable it by updating the enable_mcp setting in the configuration file or by setting the environment variable. For details, see the Configuration - MCP. After enabled, the "Generate Token" button will appear on "User Settings" -> "Security" page in the desktop version.

Integration with AI Tools

The MCP service of ezBookkeeping requires a special token to access. You can go to "User Settings" -> "Security" and click the "Generate Token" button in desktop version, and then enter your password. Alternatively, you can generate the token by the user-session-new command in ezBookkeeping's CLI, for more details, see the Command Line.

If the IP address used to access the MCP server is fixed (e.g., within a home network), you can restrict specific IP addresses that can access the MCP server. For details, see the Configuration - MCP.

Then, copy the following code into your AI tool's MCP server configuration to enable it to access and interact with ezBookkeeping data.

json
{
    "mcpServers": {
        "ezbookkeeping-mcp": {
            "type": "streamable-http",
            "url": "http://{domain}/mcp",
            "headers": {
                "Authorization": "Bearer {token}"
            }
        }
    }
}

Supported MCP Tool

Add transaction

MCP Tool Name

add_transaction

Request Parameters

FieldTypeRequiredDescription
typestringRequiredTransaction type (income, expense, transfer)
timestringRequiredTransaction time in RFC 3339 format (e.g. 2023-01-01T12:00:00Z)
category_namestringRequiredSecondary category name for the transaction
account_namestringRequiredAccount name for the transaction
amountstringRequiredTransaction amount
destination_account_namestringOptionalDestination account name for transfer transactions
destination_amountstringOptionalDestination amount for transfer transactions
tagsstring[]OptionalList of tags associated with the transaction (maximum 10 tags allowed)
commentstringOptionalTransaction description
dry_runbooleanOptionalIf true, the transaction will not be saved, only validated

Response Parameters

FieldTypeRequiredDescription
successbooleanRequiredIndicates whether this operation is successful
dry_runbooleanOptionalIndicates whether this operation is a dry run (transaction not added actually)
account_balancenumberOptionalAccount balance (or outstanding balance for debt accounts) after the transaction
destination_account_balancenumberOptionalDestination account balance (or outstanding balance for debt accounts) after the transaction (only for transfer transactions)

Query transactions

MCP Tool Name

query_transactions

Request Parameters

FieldTypeRequiredDescription
start_timestringRequiredStart time for the query in RFC 3339 format (e.g. 2023-01-01T12:00:00Z)
end_timestringRequiredEnd time for the query in RFC 3339 format or (e.g. 2023-01-01T12:00:00Z)
typestringOptionalTransaction type to filter by (income, expense, transfer)
category_namestringOptionalPrimary or secondary category name to filter transactions by
account_namestringOptionalAccount name to filter transactions by
commentstringOptionalKeyword to search in transaction description
countnumberOptionalMaximum number of results to return (default: 100)
pagenumberOptionalPage number for pagination (default: 1)
response_fieldsstringOptionalComma-separated list of optional fields to include in the response (leave empty for all fields, available fields: time, currency, category_name, account_name, comment)

Response Parameters

FieldTypeRequiredDescription
total_countnumberRequiredTotal number of transactions matching the query
current_pagenumberRequiredCurrent page number of the results
total_pagenumberRequiredTotal number of pages available for the query, calculated based on total_count and count
transactionsMCPTransactionInfo[]RequiredList of transactions matching the query

MCPTransactionInfo

FieldTypeRequiredDescription
timestringOptionalTime of the transaction in RFC 3339 format (e.g. 2023-01-01T12:00:00Z)
typestringRequiredTransaction type (income, expense, transfer)
amountstringRequiredAmount of the transaction in the specified currency
currencystringOptionalCurrency code of the transaction (e.g. USD, EUR)
category_namestringOptionalSecondary category name for the transaction
account_namestringOptionalAccount name for the transaction
destination_amountstringOptionalDestination amount for transfer transactions
destination_currencystringOptionalCurrency code of the destination amount for transfer transactions
destination_account_namestringOptionalDestination account name for transfer transactions
commentstringOptionalDescription of the transaction

Query all account names

MCP Tool Name

query_all_accounts

Request Parameters

None

Response Parameters

FieldTypeRequiredDescription
cashAccountsstring[]OptionalList of cash account names
checkingAccountsstring[]OptionalList of checking account names
savingsAccountsstring[]OptionalList of savings account names
creditCardAccountsstring[]OptionalList of credit card account names
virtualAccountsstring[]OptionalList of virtual account names
debtAccountsstring[]OptionalList of debt account names
receivableAccountsstring[]OptionalList of receivable account names
certificateOfDepositAccountsstring[]OptionalList of certificate of deposit account names
investmentAccountsstring[]OptionalList of investment account names

Query all account balances

MCP Tool Name

query_all_accounts_balance

Request Parameters

None

Response Parameters

FieldTypeRequiredDescription
cashAccountsMCPAccountBalanceInfo[]OptionalList of cash account balances
checkingAccountsMCPAccountBalanceInfo[]OptionalList of checking account balances
savingsAccountsMCPAccountBalanceInfo[]OptionalList of savings account balances
creditCardAccountsMCPAccountBalanceInfo[]OptionalList of credit card account outstanding balances
virtualAccountsMCPAccountBalanceInfo[]OptionalList of virtual account balances
debtAccountsMCPAccountBalanceInfo[]OptionalList of debt account outstanding balances
receivableAccountsMCPAccountBalanceInfo[]OptionalList of receivable account balances
certificateOfDepositAccountsMCPAccountBalanceInfo[]OptionalList of certificate of deposit account balances
investmentAccountsMCPAccountBalanceInfo[]OptionalList of investment account balances

MCPAccountBalanceInfo

FieldTypeRequiredDescription
namestringRequiredAccount name
typestringRequiredAccount type (asset or liability)
balancestringOptionalCurrent balance of the account
outstandingBalancestringOptionalCurrent outstanding balance of the account (positive value indicates amount owed)
currencystringRequiredCurrency code of the account (e.g. USD, EUR)

Query all transaction category names

MCP Tool Name

query_all_transaction_categories

Request Parameters

None

Response Parameters

FieldTypeRequiredDescription
incomeCategoriesMap<string, string[]>RequiredList of income categories, field key is the primary category name, field value is the list of secondary category names
expenseCategoriesMap<string, string[]>RequiredList of expense categories, field key is the primary category name, field value is the list of secondary category names
transferCategoriesMap<string, string[]>RequiredList of transfer categories, field key is the primary category name, field value is the list of secondary category names

Query all transaction tag names

MCP Tool Name

query_all_transaction_tags

Request Parameters

None

Response Parameters

FieldTypeRequiredDescription
tagsstring[]RequiredList of transaction tags

Query latest exchange rates

MCP Tool Name

query_latest_exchange_rates

Request Parameters

FieldTypeRequiredDescription
currenciesstringRequiredComma-separated list of currencies to query exchange rates for (e.g. USD,CNY,EUR)

Response Parameters

FieldTypeRequiredDescription
base_currencystringRequiredBase currency code (e.g. USD)
update_timestringRequiredLast update time of the exchange rates in RFC 3339 format (e.g. "2023-01-01T12:00:00Z")
ratesMCPQueryExchangeRateInfo[]RequiredExchange rates for the specified currencies

MCPQueryExchangeRateInfo

FieldTypeRequiredDescription
currencystringRequiredCurrency code (e.g. USD)
rate_to_basestringRequiredThe amount of the base currency that can be obtained for 1 unit of this currency

Released under the MIT License.