AI Agent Integration Guide

The canonical handoff document for an AI assistant connecting to Leenops.

This is the canonical starting point when a person asks an AI assistant to connect to Leenops.

Never ask the user to paste an API key into chat. Ask them to create a least-privilege key and save it through their AI client's secret, environment-variable, or MCP configuration interface.

Canonical URLs

PurposeURL
Documentationhttps://docs.leenops.com/docs/api
Agent guidehttps://docs.leenops.com/docs/api/agent-guide
REST APIhttps://workspace.leenops.com/api/v1
Hosted MCP APIhttps://workspace.leenops.com/api/mcp
OpenAPI statushttps://docs.leenops.com/docs/api/openapi
Short machine indexhttps://docs.leenops.com/llms.txt
Complete agent bundlehttps://docs.leenops.com/llms-full.txt
Integration supportsupport@leenops.com

Use the workspace.leenops.com origin directly. The apex and www origins are marketing surfaces, and some clients remove Authorization while following a cross-host redirect.

Choose the integration surface

NeedUseWhy
Let an AI assistant inspect and act on LeenopsMCPLive tool schemas and permissions are discoverable per key
Build a conventional service against a field-documented endpointRESTStable resource-oriented HTTP contract
Need an operation absent from the public status pageMCP or stopAn unlisted application route is not a supported external contract
Receive eventsModule webhookSigned, asynchronous delivery
Run a short human-approved evaluationAgent trialGuarded tool allowlist, expiry, and quota

For broad agent automation, MCP is the recommended surface. The REST status status page lists only the supported public REST contract. OpenAPI publication is temporarily paused; do not use a cached specification or probe unlisted application routes.

MCP integration protocol

Follow these steps in order:

  1. Ask an Admin or Owner to open Settings > AI > External Connections > API Keys.
  2. Create a separate temporary key for this integration.
  3. Grant the smallest relevant preset or scope set and set an expiry for testing.
  4. Configure leenops-mcp using the client's secret/configuration mechanism.
  5. Verify the key with GET /api/mcp/session.
  6. Retrieve live schemas with GET /api/mcp/tools/list?includeDenied=true&includeSchemas=true.
  7. Choose a tool from allowedToolNames; never invent a tool name or argument.
  8. Run a read-only tool first.
  9. Explain the exact impact before any write, even when the MCP client does not provide a confirmation UI.
  10. Use disposable records for mutation tests, clean them up, and revoke the temporary key.

Pin the currently verified public package during reproducible tests:

npx -y leenops-mcp@2.0.4 \
  --api-key="$LEENOPS_API_KEY" \
  --api-url="https://workspace.leenops.com"

See MCP setup for client-specific configuration and Tool Discovery for the hosted endpoints.

REST integration protocol

  1. Confirm that the intended operation is listed in Public API Status.
  2. Read its endpoint guide. Do not derive fields from a route name.
  3. Create a key with the documented scope.
  4. Send a read-only request and record its response envelope.
  5. Test validation with a disposable request.
  6. For writes, identify whether the action is reversible, soft-delete, or permanent.
  7. Add bounded retries only for network errors, 429, and retryable 5xx.
  8. Do not retry 400, 401, 403, 404, or 422 unchanged.
  9. Honor Retry-After and make retryable mutations idempotent in the caller.
  10. Remove test data and revoke the temporary key.

If an operation is not listed, use an equivalent permitted MCP tool or email support. Do not guess a body from database fields, UI labels, or another module.

Authentication and secret handling

API keys start with wks_ and are workspace-bound:

Authorization: Bearer wks_example

The key must not appear in:

  • chat messages or prompts;
  • screenshots or screen recordings;
  • source code or committed .env files;
  • query strings or URLs;
  • support tickets or webhook payloads;
  • logs, traces, or analytics.

Use one key per integration. Rotation means creating a replacement, testing it, and revoking the old key.

Pre-write safety check

Before an agent writes, it must be able to answer:

  1. Which workspace will change?
  2. Which tool or HTTP operation will run?
  3. Which records and fields will change?
  4. Is the operation reversible?
  5. Is a duplicate request safe?
  6. What permission authorizes it?
  7. How will the result be verified?
  8. How will test data be removed?

If any answer is unknown, stop and retrieve the live schema, read the endpoint guide, or contact support.

Error decision

ResultAgent action
400 / 422Correct the request using the documented/live schema; do not blindly retry
401Verify secret storage, bearer format, expiry, revocation, and canonical host
403Inspect scopes/permissions; do not request broader access without explaining why
404Verify resource ID, workspace ownership, path, and whether the route/tool exists
409Read the conflict response and current resource state before deciding
429Honor Retry-After; use exponential backoff with jitter
5xxRetry only safe/idempotent operations within a bounded budget
Missing MCP toolCheck /api/mcp/session, denied tools, features, and --read-only
Ambiguous contractStop; do not infer fields

See Troubleshooting for detailed diagnostics.

Escalate to Leenops

Email support@leenops.com with:

  • workspace ID, never the API key;
  • UTC timestamp;
  • REST method/path or MCP tool name;
  • HTTP status;
  • request, delivery, or correlation ID when present;
  • sanitized input and response body;
  • client and leenops-mcp version;
  • whether the failure is reproducible;
  • expected and actual behavior.

Redact credentials, personal data not required for diagnosis, attachment URLs, and capability tokens.

Definition of done

An integration is ready when:

  • the key is least-privilege and separately revocable;
  • authentication and a read-only smoke test pass;
  • all used schemas are documented or retrieved live;
  • writes were tested against disposable data;
  • 401, 403, 429, and retryable 5xx behavior were exercised;
  • duplicate delivery/call behavior is safe;
  • logs contain no secrets;
  • cleanup and key rotation are documented.