omnifocus-mcp
Version:
Model Context Protocol (MCP) server that integrates with OmniFocus for AI assistant interaction
33 lines (32 loc) • 1.23 kB
JavaScript
import { executeOmniFocusScript } from './utils/scriptExecution.js';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
// Get the current directory
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
async function testScript() {
try {
console.log('Executing OmniFocus script...');
const data = await executeOmniFocusScript('@omnifocusDump.js');
console.log('Script execution result:');
console.log(data);
// Save the data to a file
const outputPath = path.join(__dirname, '..', 'dist', 'scriptResult.json');
fs.writeFileSync(outputPath, JSON.stringify(data, null, 2));
console.log(`Script result saved to: ${outputPath}`);
// Check if we got valid data
if (data && data.tasks && Array.isArray(data.tasks)) {
console.log(`Successfully retrieved ${data.tasks.length} tasks directly from OmniFocus`);
}
else {
console.log('Failed to get valid task data from OmniFocus');
}
}
catch (error) {
console.error('Error executing test:', error);
}
}
// Run the test
testScript();