Skip to content
safran

Type to search. Enter opens the first result.

    Confluence

    The confluence doc source fetches wiki pages by URL and returns them as Markdown. It exists for one job: a ticket links to a specification, and the agent reading the ticket needs that page. It does not search or crawl; it fetches a page only when given a URL it recognises as its own. It works with Confluence Cloud (REST v2) and Data Center / Server (REST v1), and it is read-only.

    Profile entry

    - id: wiki
      type: confluence
      url: https://acme.atlassian.net
      email_env: JIRA_EMAIL
      token_env: CONFLUENCE_TOKEN
      spaces: [PAY]
    fetch-page.ts
    import { createSafran, isSafranError } from "@safran/core";
    
    await using safran = await createSafran({ profile: "safran.yaml" });
    
    const url = "https://acme.atlassian.net/wiki/spaces/PAY/pages/123456/Refund+rules";
    
    // Offline: does any doc source in the profile recognise this URL?
    if (safran.docs.canFetch(url)) {
      try {
        const page = await safran.docs.fetch(url);
        console.log(page.source, page.title, page.updatedAt);
        console.log(page.content);
      } catch (error) {
        if (isSafranError(error, "FORBIDDEN")) console.error("That page is in a space this profile does not allow.");
        else throw error;
      }
    }

    Agents reach the same thing through the MCP tool fetch_linked_doc; see the MCP overview.

    Authentication

    DeploymentWhat is sentWhat you need
    cloud (default)Authorization: Basic with the account e-mail and an API tokenemail_env and token_env. email_env is required on Cloud.
    datacenterAuthorization: Bearer with a personal access tokentoken_env only.
    datacenter with email_envAuthorization: Basic with that user name and the token as passwordFor servers without personal access tokens.

    The source names no scope. The account needs permission to view the pages you want fetched. Confluence answers 404 both for a page that does not exist and for one the account may not view; Safran reports NOT_FOUND with a hint that says so.

    On Cloud, url is the site root; /wiki is added for you (and not added twice if you include it).

    Data Center

    - id: wiki
      type: confluence
      url: https://wiki.acme.test/confluence
      deployment: datacenter
      token_env: CONFLUENCE_TOKEN
      spaces: [PAY, ARCH]

    url is the Confluence base URL, including its context path. Read the caveats: the Data Center path is unverified.

    Configuration reference

    FieldTypeDefaultRequiredMeaning
    idstringyesName of this entry; the source of every page it returns.
    type"confluence"yesSelects this plugin.
    urlURLyesCloud: the site root, e.g. https://acme.atlassian.net. Data Center: the Confluence base URL. No credentials, query string or fragment.
    deploymentcloud or datacentercloudnocloud: REST v2, Basic e-mail + API token. datacenter: REST v1, Bearer personal access token.
    email_envvariable nameon CloudVariable holding the account e-mail (Cloud), or the user name for Basic auth on Data Center.
    token_envvariable nameyesVariable holding the API token or personal access token.
    spacesstring[][]noSpace keys that may be read, at most 250. Empty means every space the token can see.

    Which URLs are recognised

    matchUrl decides offline. A URL is this source's when it is http or https, on the configured origin, below the configured base path, carries no credentials, is at most CONFLUENCE_MAX_URL_LENGTH characters long, and has one of these shapes (shown relative to the base, which is https://acme.atlassian.net/wiki in the example):

    URLHow the page is found
    /spaces/PAY/pages/123456/Refund+rulesBy the id in the path
    /spaces/PAY/pages/edit/123456, /spaces/PAY/pages/edit-v2/123456By the id in the path
    /pages/viewpage.action?pageId=123456By the id in the query
    /api/v2/pages/123456, /rest/api/content/123456By the id in the path
    /x/AbCd (short link)By following Confluence's redirect
    /pages/tinyurl.action?urlIdentifier=AbCdBy following Confluence's redirect
    /display/PAY/Refund+rulesBy following the redirect (Cloud) or by space key and title (Data Center)
    /pages/viewpage.action?spaceKey=PAY&title=Refund+rulesThe same

    Not recognised: space overviews, blog posts, attachments, anything on another host, and other applications on the same host. https://acme.atlassian.net/browse/PAY-1423 is a Jira URL and is not below /wiki. Having /wiki/ somewhere in a path is not enough, because other wikis appear in tickets all the time.

    A URL nobody recognises is never fetched: safran.docs.fetch fails with UNSUPPORTED and lists the configured doc sources. Safran does not fetch arbitrary URLs.

    Three safety rules

    Only the configured host is ever contacted. Tickets link to other tenants and other sites. The credentials must not leave yours, so every request, redirects included, goes to the origin in the profile. Nothing follows a redirect automatically: each one is inspected first.

    • A redirect to a sign-in address means the credentials were not accepted: AUTH_FAILED, with a hint naming the variables.
    • A redirect to any other host fails with UPSTREAM and names that host.

    The space allow-list is checked against the page Confluence returns, not against the space key in the URL. Pages move, and URLs are typed by hand. When spaces is not empty, a page whose actual space is not listed fails with FORBIDDEN:

    forbidden.ts
    import { createSafran, isSafranError } from "@safran/core";
    
    await using safran = await createSafran({ profile: "safran.yaml" });
    
    try {
      // The URL says PAY, but the page was moved to the HR space.
      await safran.docs.fetch("https://acme.atlassian.net/wiki/spaces/PAY/pages/987654/Salary+bands");
    } catch (error) {
      if (isSafranError(error, "FORBIDDEN")) console.error(error.message, error.hint);
      else throw error;
    }

    On Cloud a page names its space by id, so the connector looks up the ids of the allowed keys once per instance. If that lookup fails, the call fails: the list is a safety gate and is never skipped.

    Short links are resolved by Confluence, not decoded locally. A short link (/x/…) carries no page id. The connector asks Confluence for it and follows the redirect chain hop by hop, at most CONFLUENCE_MAX_REDIRECT_HOPS hops, each one on the configured origin, until a URL names a page id. The page is then loaded and checked like any other. A chain that ends without a page is NOT_FOUND; one that does not end is UPSTREAM with a hint to use the full page URL.

    What a page contains

    DocPage fieldValue
    sourceThe entry id, wiki
    urlThe page's canonical web URL, built from what Confluence returned, not the URL you passed
    titleThe page title
    contentThe page body converted from Confluence storage format to Markdown
    updatedAtWhen the current version was created
    authorThe author of the current version

    On Cloud, the stored body refers to people by account id. The connector resolves the author and up to CONFLUENCE_MAX_USER_LOOKUPS mentioned users to display names in one request. That lookup is best effort: if it fails, the page is returned without names.

    Page content is third-party text. When it reaches an agent through the MCP server it is wrapped as untrusted data; see security.

    Limits

    ConstantValueMeaning
    CONFLUENCE_MAX_REDIRECT_HOPS5Redirect hops followed when resolving a short link.
    CONFLUENCE_MAX_URL_LENGTH2048Longest URL looked at.
    CONFLUENCE_MAX_USER_LOOKUPS50Mentioned users resolved to names per page.

    spaces holds at most 250 keys, the largest list the space lookup takes in one request.

    Errors you may see

    CodeWhen
    UNSUPPORTEDNo doc source in the profile recognises the URL.
    INVALID_INPUTThe string is not an http(s) URL.
    FORBIDDENThe page is in a space that is not in spaces.
    NOT_FOUNDThe page or link does not exist, or the account may not view it.
    AUTH_FAILEDThe credentials were rejected, or Confluence redirected to its sign-in page.
    AUTH_MISSINGA variable named by email_env or token_env is not set.
    UPSTREAMA redirect left the configured site, or the answer was not what the API returns (a proxy or login page).

    Known caveats

    This connector is implemented from Atlassian's published API documents and tested against recorded-shape fixtures; it has not been run against a live Confluence. See verification status. The Cloud resources were checked against the Cloud v2 OpenAPI document. The Data Center documentation could not be read, so the following are marked UNVERIFIED in the source:

    • Data Center page loading. The content resource (/rest/api/content/<id>), the names it is asked to expand (body, space, version), where the author's name and the version date sit in the answer, and the Bearer personal access token header.
    • Data Center title links. /display/KEY/Title links render in place on Data Center instead of redirecting to a page id, so the page is looked up by space key and title. That lookup is unverified too. It returns the first page with that title in that space.

    If a Data Center instance answers differently, expect UPSTREAM ("unexpected response"), FORBIDDEN (when spaces is set and the space cannot be read from the answer, the page is refused) or pages without author and date. You should not get content from a space you did not allow: the allow-list check reads the space from the same response as the body.

    See also