create_transaction
Create manual transactions in Norman Finance MCP Server by specifying amount, description, cashflow type, and supplier country. Automatically categorize transactions or assign VAT rates, sale types, and dates for accurate financial records.
Instructions
Create a new manual transaction.
Args:
amount: Transaction amount (positive for income, negative for expense)
description: Transaction description
category: Transaction category
date: Transaction date in YYYY-MM-DD format (defaults to today)
vat_rate: VAT rate (0, 7, 19)
sale_type: Sale type (GOODS, SERVICES)
supplier_country: Country of the supplier (DE, INSIDE_EU, OUTSIDE_EU)
cashflow_type: Cashflow type of the transaction (INCOME, EXPENSE)
category_id: Category ID of the transaction (If not provided, the transaction will be categorized automatically using AI)
Returns:
Information about the created transaction
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | ||
| cashflow_type | Yes | ||
| category_id | No | ||
| date | No | ||
| description | Yes | ||
| sale_type | No | ||
| supplier_country | Yes | ||
| vat_rate | No |
Implementation Reference
- norman_mcp/tools/transactions.py:87-145 (handler)The core handler function for the 'create_transaction' tool, decorated with @mcp.tool(). It validates inputs, constructs the transaction data, and makes a POST request to the Norman API to create a new transaction.@mcp.tool() async def create_transaction( ctx: Context, amount: float = Field(description="Transaction amount (positive for income, negative for expense)"), description: str = Field(description="Transaction description"), cashflow_type: str = Field(description="Cashflow type of the transaction (INCOME, EXPENSE)"), supplier_country: str = Field(description="Country of the supplier (DE, INSIDE_EU, OUTSIDE_EU)"), category_id: Optional[str] = Field(description="Category ID of the transaction (If not provided, the transaction will be categorized automatically using AI)"), vat_rate: Optional[int] = Field(description="VAT rate (0, 7, 19)"), sale_type: Optional[str] = Field(description="Sale type (GOODS, SERVICES)"), date: Optional[str] = Field(description="Transaction date in YYYY-MM-DD format (defaults to today)"), ) -> Dict[str, Any]: """ Create a new manual transaction. Args: amount: Transaction amount (positive for income, negative for expense) description: Transaction description category: Transaction category date: Transaction date in YYYY-MM-DD format (defaults to today) vat_rate: VAT rate (0, 7, 19) sale_type: Sale type (GOODS, SERVICES) supplier_country: Country of the supplier (DE, INSIDE_EU, OUTSIDE_EU) cashflow_type: Cashflow type of the transaction (INCOME, EXPENSE) category_id: Category ID of the transaction (If not provided, the transaction will be categorized automatically using AI) Returns: Information about the created transaction """ api = ctx.request_context.lifespan_context["api"] company_id = api.company_id if cashflow_type not in ["INCOME", "EXPENSE"]: return {"error": "cashflow_type must be either 'INCOME' or 'EXPENSE'"} # Use current date if not provided if not date: date = datetime.now().strftime("%Y-%m-%d") transactions_url = urljoin( config.api_base_url, f"api/v1/companies/{company_id}/accounting/transactions/" ) transaction_data = { "amount": abs(amount) if cashflow_type == "INCOME" else -abs(amount), # Ensure positive amount for expenses "description": description, "cashflowType": cashflow_type, "valueDate": date, "vatRate": vat_rate, "saleType": sale_type if sale_type else "", "supplierCountry": supplier_country, "company": company_id } if category_id: transaction_data["category_id"] = category_id return api._make_request("POST", transactions_url, json_data=transaction_data)
- norman_mcp/server.py:331-331 (registration)Top-level registration call in the MCP server setup that invokes register_transaction_tools(server), which in turn registers the create_transaction tool via its @mcp.tool() decorator.register_transaction_tools(server)
- norman_mcp/server.py:19-19 (registration)Import statement for the register_transaction_tools function used to register transaction-related tools including create_transaction.from norman_mcp.tools.transactions import register_transaction_tools
- Pydantic Field definitions providing input schema and descriptions for the create_transaction tool parameters.async def create_transaction( ctx: Context, amount: float = Field(description="Transaction amount (positive for income, negative for expense)"), description: str = Field(description="Transaction description"), cashflow_type: str = Field(description="Cashflow type of the transaction (INCOME, EXPENSE)"), supplier_country: str = Field(description="Country of the supplier (DE, INSIDE_EU, OUTSIDE_EU)"), category_id: Optional[str] = Field(description="Category ID of the transaction (If not provided, the transaction will be categorized automatically using AI)"), vat_rate: Optional[int] = Field(description="VAT rate (0, 7, 19)"), sale_type: Optional[str] = Field(description="Sale type (GOODS, SERVICES)"), date: Optional[str] = Field(description="Transaction date in YYYY-MM-DD format (defaults to today)"), ) -> Dict[str, Any]: