Skip to main content
Glama

create_from_url

Capture web content directly into DEVONthink by providing a URL, with options to customize formatting, organization, and metadata for efficient knowledge management.

Instructions

Create a record in DEVONthink from a web URL.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe web URL to capture
nameNoName for the new record (defaults to page title)
parentGroupUuidNoUUID of the parent group to place the new record in
readabilityNoUse readability mode to strip navigation and ads (where supported)
userAgentNoCustom HTTP User-Agent header for the request
referrerNoHTTP Referer header for the request
pdfOptionsNoPDF-specific options (only applies when format is 'pdf')
databaseNameNoTarget database name; uses current database if omitted

Implementation Reference

  • The tool definition, registration, and handler (run) function for "create_from_url".
    export const createFromUrlTool = defineTool({
      name: "create_from_url",
      description: "Create a record in DEVONthink from a web URL.",
      schema: z.object({
        url: z.string().url().describe("The web URL to capture"),
        format: z
          .enum(FORMAT_VALUES)
          .describe(
            "Capture format: formatted_note, markdown, pdf, or web_document"
          ),
        name: z
          .string()
          .optional()
          .describe("Name for the new record (defaults to page title)"),
        parentGroupUuid: z
          .string()
          .optional()
          .describe("UUID of the parent group to place the new record in"),
        readability: z
          .boolean()
          .optional()
          .describe("Use readability mode to strip navigation and ads (where supported)"),
        userAgent: z
          .string()
          .optional()
          .describe("Custom HTTP User-Agent header for the request"),
        referrer: z
          .string()
          .optional()
          .describe("HTTP Referer header for the request"),
        pdfOptions: z
          .object({
            pagination: z
              .boolean()
              .optional()
              .describe("Enable pagination in the PDF"),
            width: z
              .number()
              .int()
              .positive()
              .optional()
              .describe("Page width in pixels for the PDF"),
          })
          .optional()
          .describe("PDF-specific options (only applies when format is 'pdf')"),
        databaseName: z
          .string()
          .optional()
          .describe(
            "Target database name; uses current database if omitted"
          ),
      }),
      run: async (args, executor) => {
        const {
          url,
          format,
          name,
          parentGroupUuid,
          readability,
          userAgent,
          referrer,
          pdfOptions,
          databaseName,
        } = args;
    
        const script = `
          ${JXA_APP}
          var url = ${jxaLiteral(url)};
          var format = ${jxaLiteral(format)};
          var name = ${jxaLiteral(name ?? null)};
          var parentGroupUuid = ${jxaLiteral(parentGroupUuid ?? null)};
          var readability = ${jxaLiteral(readability ?? false)};
          var userAgent = ${jxaLiteral(userAgent ?? null)};
          var referrer = ${jxaLiteral(referrer ?? null)};
          var pdfPagination = ${jxaLiteral(pdfOptions?.pagination ?? null)};
          var pdfWidth = ${jxaLiteral(pdfOptions?.width ?? null)};
          var dbName = ${jxaLiteral(databaseName ?? null)};
    
          // Resolve target database
          var targetDb;
          if (dbName) {
            var dbs = app.databases();
            targetDb = null;
            for (var i = 0; i < dbs.length; i++) {
              if (dbs[i].name() === dbName) { targetDb = dbs[i]; break; }
            }
            if (!targetDb) throw new Error("Database not found: " + dbName);
          } else {
            targetDb = app.currentDatabase();
          }
    
          // Resolve parent group
          var parentGroup = null;
          if (parentGroupUuid) {
            parentGroup = app.getRecordWithUuid(parentGroupUuid);
            if (!parentGroup || !parentGroup.uuid()) {
              throw new Error("Parent group not found for UUID: " + parentGroupUuid);
            }
          } else {
            parentGroup = targetDb.root();
          }
    
          // Build common options
          var opts = {in: parentGroup};
          if (name) opts["name"] = name;
          if (readability) opts["readability"] = true;
          if (userAgent) opts["agent"] = userAgent;
          if (referrer) opts["referrer"] = referrer;
    
          var record;
    
          if (format === "formatted_note") {
            record = app.createFormattedNoteFrom(url, opts);
    
          } else if (format === "markdown") {
            record = app.createMarkdownFrom(url, opts);
    
          } else if (format === "pdf") {
            if (pdfPagination !== null) opts["paginate"] = pdfPagination;
            if (pdfWidth !== null) opts["width"] = pdfWidth;
            record = app.createPDFDocumentFrom(url, opts);
    
          } else if (format === "web_document") {
            record = app.createWebDocumentFrom(url, opts);
    
          } else {
            throw new Error("Unknown format: " + format);
          }
    
          if (!record || !record.uuid()) throw new Error("Failed to create record from URL: " + url);
    
          JSON.stringify(${JXA_RECORD_PROPS});
        `;
    
        const result = executor.run(script);
        return JSON.parse(result.stdout);
      },
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mnott/Devon'

If you have feedback or need assistance with the MCP directory API, please join our Discord server