MCP网页时间戳
](https://www.npmjs.com/package/mcp-webpage-timestamps)  ](https://nodejs.org/) ](https://smithery.ai/server/@Fabien-desablens/mcp-webpage-timestamps)
一个强大的 模型上下文协议(MCP) 用于提取网页创建、修改和发布时间戳的服务器。该工具专为网页抓取和网页内容的时间分析而设计。
特性
- 全面的时间戳提取:从网页中提取创建、修改和发布时间戳
- 多个数据源:支持HTML元标记、HTTP标头、JSON-LD、微数据、OpenGraph、推特卡和启发式分析
- 信心评分:为提取的时间戳提供置信度(高/中/低)
- 批处理:同时从多个URL中提取时间戳
- 可配置的:可定制的超时、用户代理、重定向处理和启发式选项
- 生产就绪:强大的错误处理、全面的日志记录和TypeScript支持
安装
快速安装
npm install -g mcp-webpage-timestamps使用npx
npx mcp-webpage-timestamps通过Smithery安装
通过以下方式自动安装Claude Desktop的mcp网页时间戳 史密瑟里:
npx -y @smithery/cli install @Fabien-desablens/mcp-webpage-timestamps --client claude先决条件
- Node.js 18.0.0或更高版本
- npm或纱线
开发安装
git clone https://github.com/Fabien-desablens/mcp-webpage-timestamps.git
cd mcp-webpage-timestamps
npm install
npm run build用法
作为MCP服务器
该服务器可以与任何兼容MCP的客户端一起使用。以下是如何配置它:
Claude桌面配置
添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"webpage-timestamps": {
"command": "npx",
"args": ["mcp-webpage-timestamps"],
"env": {}
}
}
}临床配置
添加到MCP设置中:
{
"mcpServers": {
"webpage-timestamps": {
"command": "npx",
"args": ["mcp-webpage-timestamps"]
}
}
}直接使用
# Start the server
npm start
# Or run in development mode
npm run devapi参考
工具
extract_timestamps
从单个网页提取时间戳。
参数:
url(string,必填):从中提取时间戳的网页的URLconfig(对象,可选):配置选项
配置选项:
timeout(number):请求超时(毫秒)(默认值:10000)userAgent(string):请求的用户代理字符串followRedirects(boolean):是否遵循HTTP重定向(默认值:true)maxRedirects(number):要遵循的最大重定向数(默认值:5)enableHeuristics(boolean):启用启发式时间戳检测(默认值:true)
例子:
{
"name": "extract_timestamps",
"arguments": {
"url": "https://example.com/article",
"config": {
"timeout": 15000,
"enableHeuristics": true
}
}
}batch_extract_timestamps
批量从多个网页中提取时间戳。
参数:
urls(字符串数组,必填):从中提取时间戳的URL数组config(对象,可选):与相同的配置选项extract_timestamps
例子:
{
"name": "batch_extract_timestamps",
"arguments": {
"urls": [
"https://example.com/article1",
"https://example.com/article2",
"https://example.com/article3"
],
"config": {
"timeout": 10000
}
}
}响应格式
这两个工具都返回具有以下结构的JSON对象:
{
url: string;
createdAt?: Date;
modifiedAt?: Date;
publishedAt?: Date;
sources: TimestampSource[];
confidence: 'high' | 'medium' | 'low';
errors?: string[];
}时间戳来源:
{
type: 'html-meta' | 'http-header' | 'json-ld' | 'microdata' | 'opengraph' | 'twitter' | 'heuristic';
field: string;
value: string;
confidence: 'high' | 'medium' | 'low';
}支持的时间戳源
HTML元标签
article:published_timearticle:modified_timedatepubdatepublishdatelast-modifieddc.date.createddc.date.modifieddcterms.createddcterms.modified
HTTP头处理模块
Last-ModifiedDate
JSON-LD结构化数据
datePublisheddateModifieddateCreated
微观数据
datePublisheddateModified
OpenGraph
og:article:published_timeog:article:modified_timeog:updated_time
推特卡
twitter:data1(包含日期信息时)
启发式分析
- 时间元素
datetime属性 - 文本中常见的日期模式
- 与日期相关的CSS类
发展
脚本
# Development with hot reload
npm run dev
# Build the project
npm run build
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run format测试
该项目包括综合测试:
# Run all tests
npm test
# Run tests with coverage
npm test -- --coverage
# Run specific test file
npm test -- extractor.test.ts代码质量
- TypeScript:完全支持TypeScript,具有严格的类型检查
- 埃斯林特:使用推荐规则进行代码整理
- 更漂亮:代码格式
- 开玩笑:单元和集成测试
- 95%以上的测试覆盖率:全面的测试套件
例子
基本用法
import { TimestampExtractor } from './src/extractor.js';
const extractor = new TimestampExtractor();
const result = await extractor.extractTimestamps('https://example.com/article');
console.log('Published:', result.publishedAt);
console.log('Modified:', result.modifiedAt);
console.log('Confidence:', result.confidence);
console.log('Sources:', result.sources.length);自定义配置
const extractor = new TimestampExtractor({
timeout: 15000,
userAgent: 'MyBot/1.0',
enableHeuristics: false,
maxRedirects: 3
});
const result = await extractor.extractTimestamps('https://example.com');批处理
const urls = [
'https://example.com/article1',
'https://example.com/article2',
'https://example.com/article3'
];
const results = await Promise.all(
urls.map(url => extractor.extractTimestamps(url))
);用例
- 内容分析:分析网络内容的时间方面
- Web剪贴:从抓取的页面中提取时间元数据
- SEO分析:分析发布和修改模式
- 研究:研究网络内容的时间方面
- 内容管理:跟踪内容生命周期和更新
错误处理
提取器优雅地处理各种错误情况:
- 网络错误:超时、连接被拒绝、DNS解析失败
- HTTP错误:404、500和其他HTTP状态码
- 解析错误:HTML无效,JSON-LD格式错误,日期不可分析
- 配置错误:无效的URL、超时值等。
所有错误都记录在 errors 响应数组,允许稳健的错误处理和调试。
贡献
我们欢迎捐款!请查看我们的 贡献指南 了解详情。
开发设置
- 分叉存储库
- 克隆你的叉子:
git clone https://github.com/Fabien-desablens/mcp-webpage-timestamps.git - 安装依赖项:
npm install - 创建分支:
git checkout -b feature/your-feature - 进行更改
- 运行测试:
npm test - 提交您的更改:
git commit -m 'Add some feature' - 推到分支:
git push origin feature/your-feature - 提交拉取请求
代码的风格
- 遵循现有代码样式
- 对所有新代码使用TypeScript
- 添加新功能的测试
- 根据需要更新文档
许可证
MIT许可证-请参阅 许可证 文件以获取详细信息。
支持
- 问题:
- 讨论:
- 文档: 维基
更新日志
看 更改日志.md 查看详细的变化历史。
