- 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. |
||
|---|---|---|
| .. | ||
| src | ||
| CHANGELOG.md | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| tsup.config.ts | ||
@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 titledescription- Open Graph descriptionimage- Open Graph image URLurl- Open Graph canonical URLtype- Content type (article, website, etc.)site_name- Website namelocale- Content locale
Twitter Card Tags
Common Twitter tags extracted (keys without twitter: prefix):
card- Card type (summary, summary_large_image, etc.)title- Twitter card titledescription- Twitter card descriptionimage- Twitter card image URLsite- Twitter username for websitecreator- 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