tpmjs/packages/tools/official/extract-meta
Ajax Davis 5c9f1a1d0a chore: update dependencies with compatibility fixes
- Update all packages to latest versions via pnpm update --latest
- Downgrade Prisma 7 to 6 (v7 requires schema migration)
- Downgrade Tailwind CSS 4 to 3 (v4 requires PostCSS migration)
- Downgrade Storybook 10 to 8 (addons not available in v10)
- Pin cheerio to 1.0.0-rc.12 via pnpm override (type exports changed)
- Fix AI SDK tool definitions: parameters -> inputSchema
- Fix cheerio types in extract-meta and table-extract tools
- Add explicit type annotations to tool execute functions
- Migrate biome config to v2.3.11 schema

All type-checks, tests, and builds pass.
2026-01-09 22:49:41 +10:00
..
src chore: update dependencies with compatibility fixes 2026-01-09 22:49:41 +10:00
CHANGELOG.md chore: version packages 2025-12-31 23:54:47 +10:00
package.json chore: update dependencies with compatibility fixes 2026-01-09 22:49:41 +10:00
README.md feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00
tsconfig.json feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00
tsup.config.ts feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00

@tpmjs/tools-extract-meta

Extract meta tags from HTML pages including title, description, Open Graph, and Twitter Cards.

Installation

npm install @tpmjs/tools-extract-meta

Usage

import { extractMetaTool } from '@tpmjs/tools-extract-meta';

// Use with AI SDK
const result = await extractMetaTool.execute({
  url: 'https://example.com',
});

console.log(result.title); // 'Example Domain'
console.log(result.description); // 'This domain is for use in illustrative examples...'
console.log(result.ogTags); // { title: '...', image: '...', ... }
console.log(result.twitterTags); // { card: 'summary', ... }

Features

  • Extracts standard meta tags (title, description, canonical)
  • Extracts all Open Graph tags (og:title, og:image, og:description, etc.)
  • Extracts all Twitter Card tags (twitter:card, twitter:image, etc.)
  • Uses OG tags as fallbacks when standard tags are missing
  • Fast HTML parsing with cheerio
  • 30 second timeout for requests
  • Comprehensive error handling

Input

  • url (string, required): The URL to extract meta tags from (must be http or https)

Output

Returns an ExtractMetaResult object:

{
  title: string | null;           // Page title (from <title> or og:title)
  description: string | null;     // Meta description
  canonical: string | null;       // Canonical URL
  ogTags: Record<string, string>; // All Open Graph tags (without 'og:' prefix)
  twitterTags: Record<string, string>; // All Twitter Card tags (without 'twitter:' prefix)
  metadata: {
    url: string;                  // Original URL
    fetchedAt: string;            // ISO timestamp
    contentType: string;          // Content-Type header
    hasOpenGraph: boolean;        // Whether page has OG tags
    hasTwitterCard: boolean;      // Whether page has Twitter Card tags
  };
}

Open Graph Tags

Common OG tags extracted (keys without og: prefix):

  • title - Open Graph title
  • description - Open Graph description
  • image - Open Graph image URL
  • url - Open Graph canonical URL
  • type - Content type (article, website, etc.)
  • site_name - Website name
  • locale - Content locale

Twitter Card Tags

Common Twitter tags extracted (keys without twitter: prefix):

  • card - Card type (summary, summary_large_image, etc.)
  • title - Twitter card title
  • description - Twitter card description
  • image - Twitter card image URL
  • site - Twitter username for website
  • creator - Twitter username for content creator

Use Cases

  • SEO analysis and auditing
  • Social media preview generation
  • Content metadata extraction
  • Website scraping and indexing
  • Link preview generation
  • Meta tag validation

Requirements

  • Node.js 18+ (uses native fetch API)

License

MIT