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

# Quickstart: Run Your First Lexera Statutory Audit

> Open an SSE connection and run an unauthenticated statutory audit in minutes. Free PLG tool for rapid automated compliance checks.

This guide walks you through your first end-to-end call to Lexera. You will open an SSE stream, capture a session endpoint, and dispatch a free statutory audit against UAE law. No API key is required for this tool, so you can verify the connection and response format before moving to paid workflows.

<Steps>
  <Step title="Open the SSE stream">
    Send a GET request to `https://lexera.dev/mcp-server/sse` to establish a persistent Server-Sent Events connection. For the free statutory audit tool, the Authorization header is optional. For paid tools, it is required.

    <CodeGroup>
      ```js theme={null}
      const response = await fetch("https://lexera.dev/mcp-server/sse", {
        headers: { "Authorization": "Bearer lex_82bea57b8c3fd39f..." }
      });

      const reader = response.body.getReader();
      const decoder = new TextDecoder();

      while (true) {
        const { value, done } = await reader.read();
        if (done) break;

        const text = decoder.decode(value);
        if (text.includes("event: endpoint")) {
          const match = text.match(/data: (\/mcp-server\/messages\?sessionId=[\w-]+)/);
          const sessionUrl = `https://lexera.dev${match[1]}`;
          // Proceed to dispatch tool...
        }
      }
      ```

      ```bash theme={null}
      curl -N -H "Accept: text/event-stream" \
        -H "Authorization: Bearer lex_82bea57b8c3fd39f..." \
        https://lexera.dev/mcp-server/sse
      ```
    </CodeGroup>
  </Step>

  <Step title="Capture the session endpoint">
    The server streams an `event: endpoint` containing your session URL. Extract the `sessionId` from the data line. The format is:

    ```text theme={null}
    data: /mcp-server/messages?sessionId=<uuid>
    ```

    Append this path to `https://lexera.dev` to build your dispatch URL.
  </Step>

  <Step title="Dispatch a statutory audit">
    POST a JSON-RPC 2.0 payload to your session URL calling `lexera_local_statutory_audit`. Include the contract text and target jurisdiction.

    <CodeGroup>
      ```js theme={null}
      await fetch(sessionUrl, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "Authorization": "Bearer lex_82bea57b8c3fd39f..."
        },
        body: JSON.stringify({
          jsonrpc: "2.0",
          id: 1,
          method: "tools/call",
          params: {
            name: "lexera_local_statutory_audit",
            arguments: {
              document_text: "Vendor contract with uncapped liability clause...",
              target_jurisdiction: "UAE"
            }
          }
        })
      });
      ```

      ```bash theme={null}
      curl -X POST "$SESSION_URL" \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer lex_82bea57b8c3fd39f..." \
        -d '{
          "jsonrpc": "2.0",
          "id": 1,
          "method": "tools/call",
          "params": {
            "name": "lexera_local_statutory_audit",
            "arguments": {
              "document_text": "Vendor contract with uncapped liability clause...",
              "target_jurisdiction": "UAE"
            }
          }
        }'
      ```
    </CodeGroup>
  </Step>

  <Step title="Read the streamed result">
    The POST returns `HTTP 202 Accepted`. The actual result is streamed back over the open SSE connection. Parse the JSON-RPC response from the SSE payload to read the audit outcome.
  </Step>
</Steps>

<Note>
  `lexera_local_statutory_audit` is part of the anonymous PLG funnel. It is free, requires no authentication, and places no wallet hold. Use it to validate connectivity and response formats before moving to paid specialist routing.
</Note>

## Next steps

<CardGroup cols={3}>
  <Card title="Authentication" href="/authentication">
    Set up Bearer tokens for paid tools.
  </Card>

  <Card title="Route to a Specialist" href="/guides/route-to-specialist">
    Dispatch documents to human attorneys.
  </Card>

  <Card title="Tools Overview" href="/tools/introduction">
    Explore all MCP tools and invocation patterns.
  </Card>
</CardGroup>
