Documentation

Examples & Workflows

Examples of how to use an AI agent with PaperCast.

This page demonstrates practical workflows for using AI agents with the PaperCast MCP Server.

Prompting for an invoice

Because the AI agent can read your local playground state, you can give it high-level, declarative commands.

Example Prompt

"Connect to my active PaperCast session. Build an invoice template. Start by creating a header with our company logo on the left and the word 'INVOICE' in large, bold text on the right. Then, add a data table bound to invoice.lineItems."

Execution flow

  1. Connection: The agent uses get_active_sessions and select_active_session to establish a link to your browser tab.
  2. Layout scaffolding: It calls insert_layout_element to create a row containing two column children.
  3. Widget injection: It uses add_text_widget to insert the title and an image widget for the logo.
  4. Data binding: It calls add_table_widget and configures the bindPath to invoice.lineItems.

As the agent performs these tool calls, the changes instantly appear in your browser.

Debugging overflowing layouts

If a layout fails to wrap or a table overflows off the page, instruct the agent to fix it visually.

Example Prompt

"The line items table overflows off the right edge of the page. Inspect the schema and fix the column widths."

Execution flow

  1. State retrieval: The agent uses get_document_state to pull down your JSON schema.
  2. Analysis: It identifies the flex or width properties causing the overflow.
  3. Correction: It uses update_element_properties to apply the correct constraints.