mcpField
S
ScreenshotOne.com - MCP Server

ScreenshotOne.com - MCP Server

ローカル
github.com/mrgoonie開発ツール377 週間前に更新

ScreenshotOne.com - MCP Server について

ScreenshotOne.com - MCP Serverは、AIシステムをScreenshotOne APIに接続し、ウェブサイトやHTMLのスクリーンショットを撮影します。MCPまたはコマンドラインで設定可能な撮影を行う開発者やMCP利用者向けです。

主な機能

  1. 01URLやHTMLのスクリーンショット撮影
  2. 02ビューポートとデバイスエミュレーションの調整
  3. 03全ページまたはCSS指定要素の撮影
  4. 04PNG、JPEG、WebP、PDFでの出力
  5. 05広告、トラッカー、Cookieバナーのブロック
  6. 06CSSとJavaScriptの挿入

活用シーン

  1. 01視覚確認用のウェブサイト撮影
  2. 02HTMLの画像またはPDFへのレンダリング
  3. 03CSSで指定したページ領域の撮影

MCP 対応

ScreenshotOneのスクリーンショット機能をMCPツールとして提供します。stdioとStreamable HTTPに対応し、コマンドラインコマンドも備えています。

設定

ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。

インストール方法は未掲載です

このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。

リポジトリ

ツール

ツール一覧はまだ取得されていません

ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。

詳細

ScreenshotOne.com - MCP サーバー

このプロジェクトは、AI アシスタントを ScreenshotOne.com API に接続し、ウェブサイトのスクリーンショットを撮影する Model Context Protocol(MCP)サーバーを提供します。

利用可能な機能
  • 任意の URL のスクリーンショットを撮影
  • HTML コンテンツをレンダリングしてスクリーンショットを撮影
  • ビューポートサイズとデバイスエミュレーションをカスタマイズ
  • ページ全体のスクリーンショットを撮影
  • CSS セレクターで特定の要素を選択
  • 複数の出力形式(PNG、JPEG、WebP、PDF)
  • 広告、トラッカー、Cookie バナーをブロック
  • カスタム CSS と JavaScript を挿入
  • 待機動作とタイミングを制御

ScreenshotOne.com

サポートされているトランスポート

  • "stdio" トランスポート - CLI 使用時のデフォルトのトランスポート
  • "Streamable HTTP" トランスポート - ウェブベースのクライアント向け
    • 認証を実装(Bearer <token> を含む "Authorization" ヘッダー)
  • "sse" トランスポート (非推奨)
  • テストを作成

使い方

CLI
# Take a screenshot of a URL
npm run dev:cli -- take-screenshot --url "https://example.com" --access-key "your-access-key"

# Take a screenshot with custom viewport
npm run dev:cli -- take-screenshot --url "https://example.com" --viewport-width 1920 --viewport-height 1080

# Capture a full page screenshot
npm run dev:cli -- take-screenshot --url "https://example.com" --full-page

# Save the screenshot to a file
npm run dev:cli -- take-screenshot --url "https://example.com" --output screenshot.png

# Block ads and trackers
npm run dev:cli -- take-screenshot --url "https://example.com" --block-ads --block-trackers --block-cookie-banners

# ----------------------------------------------
# UPLOAD SCREENSHOT TO CLOUDFLARE
# REMEMBER TO SET THE ENVIRONMENT VARIABLES
# > See example at ".env.example" file
# ----------------------------------------------

# Take a screenshot and upload it to Cloudflare
npm run dev:cli -- take-screenshot --url https://example.com --upload

# Take a screenshot with a custom filename
npm run dev:cli -- take-screenshot --url https://example.com --upload --upload-filename my-screenshot

# Take a screenshot with upload debugging enabled
npm run dev:cli -- take-screenshot --url https://example.com --upload --upload-debug
MCP のセットアップ

stdio トランスポートを使用したローカル設定:

{
  "mcpServers": {
    "screenshotone": {
      "command": "node",
      "args": ["/path/to/screenshotone-mcp-server/dist/index.js"],
      "transportType": "stdio"
    }
  }
}

リモート HTTP の設定:

{
  "mcpServers": {
    "screenshotone": {
      "type": "http",
      "url": "http://localhost:8080/mcp"
    }
  }
}

HTTP トランスポートの環境変数:

以下の環境変数を使用して HTTP サーバーを設定できます。

  • MCP_HTTP_HOST:バインドするホスト(デフォルト:127.0.0.1)
  • MCP_HTTP_PORT:リッスンするポート(デフォルト:8080)
  • MCP_HTTP_PATH:エンドポイントのパス(デフォルト:/mcp)

ソースコードの概要

MCP とは?

Model Context Protocol(MCP)は、AI システムが外部のツールやデータソースに、安全かつコンテキストに応じて接続できるようにするオープン標準です。

このボイラープレートは、明確なレイヤー構造を持つアーキテクチャで MCP 仕様を実装しています。これを拡張することで、あらゆる API やデータソース向けのカスタム MCP サーバーを構築できます。

このボイラープレートを使う理由

  • 本番環境対応のアーキテクチャ:公開済みの MCP サーバーで使用されているパターンに沿っており、CLI、ツール、コントローラー、サービスが明確に分離されています。

  • 型安全性:TypeScript で構築されており、開発者体験、コード品質、保守性が向上します。

  • 動作するサンプル:CLI から API 連携までの一連のパターンを示す、完全に実装された IP 検索ツールが含まれています。

  • テストフレームワーク:カバレッジレポートを含め、単体テストと CLI 統合テストの両方に対応するテスト基盤が備わっています。

  • 開発ツール:MCP サーバー開発向けに事前設定された ESLint、Prettier、TypeScript などの品質管理ツールが含まれています。


はじめに

前提条件


ステップ 1:クローンとインストール

# Clone the repository
git clone https://github.com/mrgoonie/screenshotone-mcp-server.git
cd screenshotone-mcp-server

# Install dependencies
npm install

ステップ 2:開発サーバーを実行

stdio トランスポート(デフォルト)を使用して、開発モードでサーバーを起動します。

npm run dev:server

または、Streamable HTTP トランスポートを使用します。

npm run dev:server:http

これにより、ホットリロードが有効な MCP サーバーが起動し、http://localhost:5173 で MCP Inspector が利用可能になります。

⚙️ プロキシサーバーがポート 6277 でリッスンしています 🔍 MCP Inspector は http://127.0.0.1:6274 で起動して実行中です

HTTP トランスポートを使用する場合、デフォルトではサーバーは http://127.0.0.1:8080/mcp で利用できます。


ステップ 3:スクリーンショットツールをテスト

CLI を使用してスクリーンショットを撮影します。

# Basic screenshot
npm run dev:cli -- take-screenshot --url "https://example.com" --access-key "your-access-key"

# Advanced options
npm run dev:cli -- take-screenshot --url "https://example.com" --format png --viewport-width 1920 --viewport-height 1080 --full-page --output screenshot.png

アーキテクチャ

このボイラープレートでは、関心事を分離し、保守性を高める、明確なレイヤー構造のアーキテクチャパターンを採用しています。

プロジェクト構成

src/
├── cli/              # Command-line interfaces
├── controllers/      # Business logic
├── resources/        # MCP resources: expose data and content from your servers to LLMs
├── services/         # External API interactions
├── tools/            # MCP tool definitions
├── types/            # Type definitions
├── utils/            # Shared utilities
└── index.ts          # Entry point

レイヤーと役割

CLI レイヤー(src/cli/*.cli.ts)
  • 目的:コマンドラインインターフェースを定義し、引数を解析してコントローラーを呼び出します
  • 命名規則:ファイル名は <feature>.cli.ts にします
  • テスト:CLI 統合テストは <feature>.cli.test.ts に記述します
ツールレイヤー(src/tools/*.tool.ts)
  • 目的:AI アシスタント向けに、スキーマと説明を備えた MCP ツールを定義します
  • 命名規則:ファイル名は <feature>.tool.ts とし、型は <feature>.types.ts に記述します
  • パターン:各ツールで、引数の検証に zod を使用します
コントローラーレイヤー(src/controllers/*.controller.ts)
  • 目的:ビジネスロジックを実装し、エラーを処理して、レスポンスをフォーマットします
  • 命名規則:ファイル名は <feature>.controller.ts にします
  • パターン:標準化された ControllerResponse オブジェクトを返します
サービスレイヤー(src/services/*.service.ts)
  • 目的:外部 API またはデータソースと連携します
  • 命名規則:ファイル名は <feature>.service.ts にします
  • パターン:ロジックを最小限に抑え、API とのやり取りに徹します
ユーティリティレイヤー(src/utils/*.util.ts)
  • 目的:アプリケーション全体で共有する機能を提供します
  • 主なユーティリティ:
    • logger.util.ts:構造化ログ
    • error.util.ts:エラー処理と標準化
    • formatter.util.ts:Markdown フォーマット用ヘルパー

開発ガイド

開発スクリプト

# Start server in development mode (hot-reload & inspector)
npm run dev:server

# Run CLI in development mode
npm run dev:cli -- [command] [args]

# Build the project
npm run build

# Start server in production mode
npm run start:server

# Run CLI in production mode
npm run start:cli -- [command] [args]

テスト

# Run all tests
npm test

# Run specific tests
npm test -- src/path/to/test.ts

# Generate test coverage report
npm run test:coverage

コード品質

# Lint code
npm run lint

# Format code with Prettier
npm run format

# Check types
npm run typecheck

カスタムツールの構築

以下の手順で、独自のツールをサーバーに追加します。

1. サービスレイヤーを定義する

外部 API と連携する新しいサービスを src/services/ に作成します。

// src/services/example.service.ts
import { Logger } from '../utils/logger.util.js';

const logger = Logger.forContext('services/example.service.ts');

export async function getData(param: string): Promise<any> {
	logger.debug('Getting data', { param });
	// API interaction code here
	return { result: 'example data' };
}

2. コントローラーを作成する

ビジネスロジックを処理するコントローラーを src/controllers/ に追加します。

// src/controllers/example.controller.ts
import { Logger } from '../utils/logger.util.js';
import * as exampleService from '../services/example.service.js';
import { formatMarkdown } from '../utils/formatter.util.js';
import { handleControllerError } from '../utils/error-handler.util.js';
import { ControllerResponse } from '../types/common.types.js';

const logger = Logger.forContext('controllers/example.controller.ts');

export interface GetDataOptions {
	param?: string;
}

export async function getData(
	options: GetDataOptions = {},
): Promise<ControllerResponse> {
	try {
		logger.debug('Getting data with options', options);

		const data = await exampleService.getData(options.param || 'default');

		const content = formatMarkdown(data);

		return { content };
	} catch (error) {
		throw handleControllerError(error, {
			entityType: 'ExampleData',
			operation: 'getData',
			source: 'controllers/example.controller.ts',
		});
	}
}

3. MCP ツールを実装する

ツール定義を src/tools/ に作成します。

// src/tools/example.tool.ts
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';
import { Logger } from '../utils/logger.util.js';
import { formatErrorForMcpTool } from '../utils/error.util.js';
import * as exampleController from '../controllers/example.controller.js';

const logger = Logger.forContext('tools/example.tool.ts');

const GetDataArgs = z.object({
	param: z.string().optional().describe('Optional parameter'),
});

type GetDataArgsType = z.infer<typeof GetDataArgs>;

async function handleGetData(args: GetDataArgsType) {
	try {
		logger.debug('Tool get_data called', args);

		const result = await exampleController.getData({
			param: args.param,
		});

		return {
			content: [{ type: 'text' as const, text: result.content }],
		};
	} catch (error) {
		logger.error('Tool get_data failed', error);
		return formatErrorForMcpTool(error);
	}
}

export function register(server: McpServer) {
	server.tool(
		'get_data',
		`Gets data from the example API, optionally using \`param\`.
Use this to fetch example data. Returns formatted data as Markdown.`,
		GetDataArgs.shape,
		handleGetData,
	);
}

4. CLI サポートを追加する

CLI コマンドを src/cli/ に作成します。

// src/cli/example.cli.ts
import { program } from 'commander';
import { Logger } from '../utils/logger.util.js';
import * as exampleController from '../controllers/example.controller.js';
import { handleCliError } from '../utils/error-handler.util.js';

const logger = Logger.forContext('cli/example.cli.ts');

program
	.command('get-data')
	.description('Get example data')
	.option('--param <value>', 'Optional parameter')
	.action(async (options) => {
		try {
			logger.debug('CLI get-data called', options);

			const result = await exampleController.getData({
				param: options.param,
			});

			console.log(result.content);
		} catch (error) {
			handleCliError(error);
		}
	});

5. コンポーネントを登録する

エントリーポイントを更新して、新しいコンポーネントを登録します。

// In src/cli/index.ts
import '../cli/example.cli.js';

// In src/index.ts (for the tool)
import exampleTool from './tools/example.tool.js';
// Then in registerTools function:
exampleTool.register(server);

デバッグツール

MCP Inspector

ビジュアル MCP Inspector にアクセスして、ツールをテストし、リクエストとレスポンスの詳細を確認します。

  1. npm run dev:server を実行します
  2. ブラウザーで http://localhost:5173 を開きます
  3. UI でツールをテストし、ログを直接確認します

サーバーログ

開発用のデバッグログを有効にします。

# Set environment variable
DEBUG=true npm run dev:server

# Or configure in ~/.mcp/configs.json

MCP サーバーの公開

カスタム MCP サーバーを公開する準備ができたら、以下を行います。

  1. package.json に詳細を記入します
  2. README.md にツールのドキュメントを記載します
  3. プロジェクトをビルドします:npm run build
  4. 本番ビルドをテストします:npm run start:server
  5. npm に公開します:npm publish

ライセンス

ISC ライセンス

{
	"screenshotone": {
		"environments": {
			"DEBUG": "true",
			"SCREENSHOTONE_ACCESS_KEY": "value"
		}
	}
}

**注:**後方互換性のため、screenshotone キーが見つからない場合、サーバーは完全なパッケージ名(screenshotone-mcp-server)またはスコープなしのパッケージ名(screenshotone-mcp-server)を使った設定も認識します。ただし、新しい設定では短い screenshotone キーの使用をおすすめします。

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。