vielhuber / slopdetector
Provider-based PHP helper and MCP server for AI-text and plagiarism detection.
Requires
- php: ^8.5
- ext-curl: *
- ext-json: *
- vielhuber/simplemcp: ^1.1.4
Requires (Dev)
- phpunit/phpunit: ^13
README
🍲slopdetector🍲
slopdetector is a provider-based PHP helper and MCP server for AI-text and plagiarism detection.
the first provider is Pangram. additional providers can implement the small Provider interface without changing the public PHP or MCP API.
slopdetector requires PHP 8.5 or newer.
installation
composer require vielhuber/slopdetector
configuration
copy .env.example to .env or provide the same variables through the process environment:
PROVIDER=pangram PANGRAM_API_KEY=your_api_key MCP_TOKEN=
the API key is sent only in Pangram's x-api-key request header. text and files are transferred to Pangram for analysis. public dashboard links are disabled unless explicitly requested.
PHP
<?php declare(strict_types=1); require __DIR__ . '/vendor/autoload.php'; use vielhuber\slopdetector\slopdetector; $detector = slopdetector::create(); $models = $detector->listModels(); $result = $detector->analyzeText( text: 'Text to analyze', model: $models[0] ); print_r($result);
example response:
{
"stage": "STAGE_SUCCESS",
"text": "Text to analyze",
"version": "3.3.2",
"headline": "Human Written",
"prediction": "We believe this is human-written",
"prediction_short": "Human",
"fraction_ai": 0,
"fraction_ai_assisted": 0,
"fraction_human": 1,
"num_ai_segments": 0,
"num_ai_assisted_segments": 0,
"num_human_segments": 1,
"windows": [
{
"text": "Text to analyze",
"label": "Human Written",
"ai_assistance_score": 0.01,
"confidence": "High",
"start_index": 0,
"end_index": 15,
"word_count": 3,
"token_length": 3
}
]
}
models are discovered dynamically. analyzeText() and submitBulk() deliberately require an explicit model so the integration remains valid when Pangram makes model selection mandatory after September 30, 2026. Pangram's file endpoint currently uses its server-side default model and therefore has no model argument.
supported file formats are PDF, DOCX, and RTF:
$result = $detector->analyzeFile(filePath: '/path/to/document.pdf');
bulk jobs remain asynchronous:
$job = $detector->submitBulk( items: [ ['id' => 'article-1', 'text' => 'First text'], ['id' => 'article-2', 'text' => 'Second text'] ], model: $models[0] ); $status = $detector->getBulkStatus(bulkId: $job['bulk_id']); $results = $detector->getBulkResults(bulkId: $job['bulk_id'], offset: 0, limit: 100);
providers
providers implement vielhuber\slopdetector\Provider. the selected provider is configured through PROVIDER; currently supported: pangram.
MCP server
vendor/bin/mcp-server.php
available tools:
list_modelsanalyze_textcheck_plagiarismanalyze_filesubmit_bulkget_bulk_statusget_bulk_results
analyze_text hides Pangram's internal submit/poll cycle and returns the completed result. bulk processing exposes separate submit, status, and paginated result tools because jobs can be long-running.
tests
composer install vendor/bin/phpunit
the test suite uses a fake transport and does not send texts, files, or API credentials to Pangram.