Skip to main content
Glama

OmniFocus MCP Enhanced

by jqlts1
listCustomPerspectives.tsโ€ข2.54 kB
import { executeOmniFocusScript } from '../../utils/scriptExecution.js'; export interface ListCustomPerspectivesOptions { format?: 'simple' | 'detailed'; } export async function listCustomPerspectives(options: ListCustomPerspectivesOptions = {}): Promise<string> { const { format = 'simple' } = options; try { console.log('๐Ÿš€ ๅผ€ๅง‹ๆ‰ง่กŒ listCustomPerspectives ่„šๆœฌ...'); // Execute the list custom perspectives script const result = await executeOmniFocusScript('@listCustomPerspectives.js', {}); console.log('๐Ÿ“‹ ่„šๆœฌๆ‰ง่กŒๅฎŒๆˆ๏ผŒ็ป“ๆžœ็ฑปๅž‹:', typeof result); console.log('๐Ÿ“‹ ่„šๆœฌๆ‰ง่กŒ็ป“ๆžœ:', result); // ๅค„็†ๅ„็งๅฏ่ƒฝ็š„่ฟ”ๅ›ž็ฑปๅž‹ let data: any; if (typeof result === 'string') { console.log('๐Ÿ“ ็ป“ๆžœๆ˜ฏๅญ—็ฌฆไธฒ๏ผŒๅฐ่ฏ•่งฃๆž JSON...'); try { data = JSON.parse(result); console.log('โœ… JSON ่งฃๆžๆˆๅŠŸ:', data); } catch (parseError) { console.error('โŒ JSON ่งฃๆžๅคฑ่ดฅ:', parseError); throw new Error(`่งฃๆžๅญ—็ฌฆไธฒ็ป“ๆžœๅคฑ่ดฅ: ${result}`); } } else if (typeof result === 'object' && result !== null) { console.log('๐Ÿ”„ ็ป“ๆžœๆ˜ฏๅฏน่ฑก๏ผŒ็›ดๆŽฅไฝฟ็”จ...'); data = result; } else { console.error('โŒ ๆ— ๆ•ˆ็š„็ป“ๆžœ็ฑปๅž‹:', typeof result, result); throw new Error(`่„šๆœฌๆ‰ง่กŒ่ฟ”ๅ›žไบ†ๆ— ๆ•ˆ็š„็ป“ๆžœ็ฑปๅž‹: ${typeof result}, ๅ€ผ: ${result}`); } // ๆฃ€ๆŸฅๆ˜ฏๅฆๆœ‰้”™่ฏฏ if (!data.success) { throw new Error(data.error || 'Unknown error occurred'); } // ๆ ผๅผๅŒ–่พ“ๅ‡บ if (data.count === 0) { return "๐Ÿ“‹ **่‡ชๅฎšไน‰้€่ง†ๅˆ—่กจ**\n\nๆš‚ๆ— ่‡ชๅฎšไน‰้€่ง†ใ€‚"; } if (format === 'simple') { // ็ฎ€ๅ•ๆ ผๅผ๏ผšๅชๆ˜พ็คบๅ็งฐๅˆ—่กจ const perspectiveNames = data.perspectives.map((p: any) => p.name); return `๐Ÿ“‹ **่‡ชๅฎšไน‰้€่ง†ๅˆ—่กจ** (${data.count}ไธช)\n\n${perspectiveNames.map((name: string, index: number) => `${index + 1}. ${name}`).join('\n')}`; } else { // ่ฏฆ็ป†ๆ ผๅผ๏ผšๆ˜พ็คบๅ็งฐๅ’Œๆ ‡่ฏ†็ฌฆ const perspectiveDetails = data.perspectives.map((p: any, index: number) => `${index + 1}. **${p.name}**\n ๐Ÿ†” ${p.identifier}` ); return `๐Ÿ“‹ **่‡ชๅฎšไน‰้€่ง†ๅˆ—่กจ** (${data.count}ไธช)\n\n${perspectiveDetails.join('\n\n')}`; } } catch (error) { console.error('Error in listCustomPerspectives:', error); return `โŒ **้”™่ฏฏ**: ${error instanceof Error ? error.message : String(error)}`; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jqlts1/omnifocus-mcp-enhanced'

If you have feedback or need assistance with the MCP directory API, please join our Discord server