> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yofacturo.es/llms.txt
> Use this file to discover all available pages before exploring further.

# Tools

> Reference for the MCP tools available in the YoFacturo server.

# Tools

The server exposes **14 tools** grouped by functional area.

## Organization

### `get_user_organization_info`

Returns the active organization context (tax ID, fiscal regime, and defaults) so the agent can operate with the correct fiscal context when company or tax defaults are needed.

***

### `get_mcp_workflows_guidance`

Returns summarized MCP workflow guidance (workflow name, description, and kickoff steps) to help the agent plan or execute multistep flows.

***

## Contacts

### `list_contacts`

Search contacts in the organization with optional filters.

| Parameter         | Type    | Required | Description                          |
| ----------------- | ------- | -------- | ------------------------------------ |
| `query`           | string  | No       | Name search (case-insensitive).      |
| `document_number` | string  | No       | Filter by document number (NIF/CIF). |
| `email`           | string  | No       | Filter by email.                     |
| `page`            | integer | No       | Page number.                         |

***

### `resolve_contact`

Deterministically resolve a single contact. Returns `status` (`unique` / `ambiguous` / `none`) and up to 5 candidates. Use this before any write operation that requires a `contact_id`.

| Parameter         | Type    | Required | Description                                         |
| ----------------- | ------- | -------- | --------------------------------------------------- |
| `query`           | string  | No       | Free-text name search (case-insensitive).           |
| `document_number` | string  | No       | Exact match on NIF/CIF.                             |
| `email`           | string  | No       | Exact match on email.                               |
| `id`              | integer | No       | Exact contact id. Short-circuits all other filters. |

At least one of the four fields is required.

***

### `create_contact`

Create a new contact in the organization. Idempotent on `document_number`: if a contact with that NIF/CIF already exists, returns the existing one instead of creating a duplicate.

***

### `update_contact`

Update the fields of an existing contact. Only the fields passed are modified (PATCH semantics).

| Parameter | Type    | Required | Description                  |
| --------- | ------- | -------- | ---------------------------- |
| `id`      | integer | Yes      | Id of the contact to update. |

***

## Products

### `resolve_product`

Deterministically resolve a single product. Returns `status` (`unique` / `ambiguous` / `none`) and candidates. Use this before creating an invoice draft.

| Parameter | Type    | Required | Description               |
| --------- | ------- | -------- | ------------------------- |
| `query`   | string  | No       | Free-text concept search. |
| `id`      | integer | No       | Exact product id.         |

At least one of the two fields is required.

***

### `create_product`

Add a new product to the organization's catalogue.

***

### `update_product`

Update the fields of an existing product. Only the fields passed are modified (PATCH semantics).

| Parameter | Type    | Required | Description                  |
| --------- | ------- | -------- | ---------------------------- |
| `id`      | integer | Yes      | Id of the product to update. |

***

## Invoices

### `resolve_invoice`

Locate an existing issued invoice.

| Parameter               | Type    | Required | Description                                            |
| ----------------------- | ------- | -------- | ------------------------------------------------------ |
| `id`                    | integer | No       | Exact invoice id.                                      |
| `full_number`           | string  | No       | Full invoice number (e.g. `A-2025-0042`).              |
| `latest_for_contact_id` | integer | No       | Returns the most recent invoice for the given contact. |

***

### `create_invoice_draft`

Create an ordinary (F1) invoice draft. The draft is **not issued**; use `issue_invoice_draft` to make it fiscally binding.

Returns the `draft_id`, a `confirmation_token`, and a preview to show the user before issuing.

| Parameter                  | Type    | Required | Description                                                                        |
| -------------------------- | ------- | -------- | ---------------------------------------------------------------------------------- |
| `contact_id`               | integer | Yes      | Contact id. Use `resolve_contact` to obtain it.                                    |
| `lines`                    | array   | Yes      | At least one line. Each line must have `product_id` or (`concept` + `unit_price`). |
| `lines[].product_id`       | integer | No       | Product id. Pre-fills concept, price, and tax rate.                                |
| `lines[].concept`          | string  | No\*     | Required if no `product_id`. Overrides the product value when present.             |
| `lines[].unit_price`       | number  | No\*     | Required if no `product_id`. Overrides the product value when present.             |
| `lines[].quantity`         | number  | No       | Defaults to `1`.                                                                   |
| `lines[].tax_rate`         | number  | No       | Overrides the product's or organization's default tax rate.                        |
| `lines[].discount_percent` | number  | No       | Discount percentage.                                                               |
| `operation_date`           | string  | No       | ISO-8601 date.                                                                     |
| `operation_description`    | string  | No       | Description of the operation.                                                      |
| `payment_method`           | string  | No       | Payment method.                                                                    |
| `payment_method_info`      | string  | No       | Additional payment method information.                                             |

***

### `create_simplified_invoice_draft`

Create a simplified (F2) invoice draft, without an associated contact. Useful for tickets or general public sales.

Returns `draft_id`, `confirmation_token`, and a preview.

***

### `issue_invoice_draft`

<Warning>
  **Destructive and irreversible operation.** Once issued, the invoice is hash-chained and cannot be modified or deleted.
</Warning>

<Warning>
  Keep in mind that invoices **will not be sent to Verifactu** until you submit the request from the platform.
</Warning>

Issue a draft (F1 or F2), making it fiscally binding. The invoice is automatically submitted to VeriFactu.

| Parameter            | Type    | Required | Description                                                                       |
| -------------------- | ------- | -------- | --------------------------------------------------------------------------------- |
| `draft_id`           | integer | Yes      | Id of the draft to issue.                                                         |
| `confirmation_token` | string  | No       | Token returned by the draft creation step. Must match if one was generated.       |
| `send_email`         | boolean | No       | If `true`, sends the issued invoice by email to the contact. Defaults to `false`. |

***

### `send_invoice_email`

Send or resend an issued invoice by email to its associated contact.

| Parameter           | Type    | Required | Description               |
| ------------------- | ------- | -------- | ------------------------- |
| `issued_invoice_id` | integer | Yes      | Id of the issued invoice. |

***

## Prompt

### `create_invoice`

Full guided flow for issuing an invoice. The agent resolves the contact and products, creates the draft, presents the preview, and requests explicit confirmation before issuing.
