eewooksdevelopers
Release 0.2 documentationAPI 0.2.0 is live and verified. Check availability before integrating.

Python, Node.js and PHP examples

Choose a runnable backend client in your integration's language. All three read a complete bounded snapshot, accept the same CLI options, and use the same authentication and safety rules. No chat session or language model is needed.

Language Runtime Download
Python Python 3.10+, standard library ewooks_mcp_client.py
Node.js Node.js 22+, built-in modules ewooks_mcp_client.mjs
PHP PHP 8.1+ with ext-curl, no Composer packages ewooks_mcp_client.php.txt

Download tool definitions.

PHP is deliberately distributed as plain source text, not an executable web route. You can run the downloaded .php.txt file directly with PHP CLI, or rename it to .php on your private backend. The Node.js module is also for backend use, not browser JavaScript.

Python

Requires Python 3.10 or newer and an environment running MCP release 0.2. Set the key through your secret manager; do not put it in a command-line argument or the downloaded file.

export EWOOKS_MCP_URL='https://mcp.ewooks.fi/mcp'
# EWOOKS_MCP_KEY is provided by your secret manager.
python ewooks_mcp_client.py --from 2026-11-20 --to 2026-11-20

The default output is a record count only. For work diary sessions:

python ewooks_mcp_client.py --resource work-sessions \
  --from 2026-11-20 --to 2026-11-20

To explicitly write the authorized source records to a new local NDJSON file:

python ewooks_mcp_client.py --from 2026-11-20 --to 2026-11-20 \
  --output reviewed-source.ndjson

The file contains personal/business data. Protect it with your normal access and retention controls. A failed read does not publish a partial file. Existing output files are not overwritten.

Node.js

The environment variables are the same as for Python: EWOOKS_MCP_URL chooses the fixed production/demo endpoint, and EWOOKS_MCP_KEY comes from your secret manager.

node ewooks_mcp_client.mjs --from 2026-11-20 --to 2026-11-20
node ewooks_mcp_client.mjs --resource work-sessions \
  --from 2026-11-20 --to 2026-11-20
node ewooks_mcp_client.mjs --from 2026-11-20 --to 2026-11-20 \
  --output reviewed-source.ndjson

To reuse the reader in a backend ES module:

import { EwooksClient } from './ewooks_mcp_client.mjs';

const client = new EwooksClient(process.env.EWOOKS_MCP_URL, process.env.EWOOKS_MCP_KEY);
await client.initialize();
let count = 0;
for await (const row of client.records('drives', '2026-11-20', '2026-11-20')) {
  // Validate mappings and approval before any downstream processing.
  count++;
}
console.log(`Read ${count} source records.`);

JavaScript cannot represent every large integer exactly. This example rejects unsafe numeric record IDs instead of rounding them; IDs returned as decimal strings retain their exact value.

PHP

Enable ext-curl and keep normal TLS certificate/hostname verification enabled. The example has no CakePHP or Composer dependency. Run it from a backend command line:

php ewooks_mcp_client.php.txt --from 2026-11-20 --to 2026-11-20
php ewooks_mcp_client.php.txt --resource work-sessions \
  --from 2026-11-20 --to 2026-11-20
php ewooks_mcp_client.php.txt --from 2026-11-20 --to 2026-11-20 \
  --output reviewed-source.ndjson

To reuse the reader in your backend PHP code:

<?php
require __DIR__ . '/ewooks_mcp_client.php.txt';

$client = new EwooksMcpExampleClient(getenv('EWOOKS_MCP_URL'), getenv('EWOOKS_MCP_KEY'));
$client->initialize();
$count = 0;
foreach ($client->records('drives', '2026-11-20', '2026-11-20') as $row) {
    // Validate mappings and approval before any downstream processing.
    $count++;
}
echo "Read {$count} source records.\n";

All three CLIs accept --from, --to, --resource, --driver, --output and --help. Each prints only a record count by default. An explicitly requested NDJSON output is published only after the complete read succeeds and never overwrites an existing destination. Restrict access to output files and their parent directories.

What the examples check

  • Fixed allowlisted HTTPS production/demo endpoints, TLS verification and no redirects.
  • Initialize response, negotiated protocol version and server release before snapshot requests.
  • HTTP errors, JSON-RPC errors and tool errors separately.
  • All snapshot pages, including empty pages with a continuation cursor.
  • Duplicate source IDs, unexpected fleets and repeated cursors.
  • A bounded response size and a maximum page count.

These examples require the verified 0.2 contract and refuse an older deployment. Check release status before using them. They do not write to a target accounting system, approve records, calculate payroll, or provide a change feed. Review them as integration starting points and adapt operational alerting, bounded retry/backoff, scheduling, retention and downstream duplicate prevention to your environment.

Ewooks Developer Documentation · Updated 21 November 2026 · Synthetic examples only