A Model Context Protocol (MCP) server that provides intelligent tools for file operations, memory management, news retrieval, and email processing.
npm install dhealth_intelligenceA Model Context Protocol (MCP) server that provides intelligent tools for file operations, memory management, news retrieval, and email processing.
- File Operations
- Read file contents (supports text, image, and PDF files)
- List directory contents
- Memory Management
- Add memories with topics and notes
- Retrieve memories by topic
- Persistent storage in JSON format
- News Retrieval
- Search news by country and category
- Support for multiple news categories
- Pagination support
- Email Processing
- IMAP email retrieval
- Email parsing and processing
- PDF to image conversion
- Node.js (v16 or higher)
- npm or yarn
- TypeScript
- Bun (optional, for creating executables)
1. Clone the repository:
``bash`
git clone https://github.com/dhealthproject/dhealth-intelligence.git
cd dhealth-intelligence
2. Install dependencies:
`bash`
npm install
3. Set up environment variables:
`bashMemory file path (optional, defaults to memory.json in project root)
MEM_PATH=/path/to/memory.json
Configuration
The application uses a centralized configuration system. You can modify the default values in
src/config/index.ts:`typescript
export const config = {
memory: {
path: process.env.MEM_PATH ?? path.resolve('memory.json')
},
news: {
baseUrl: process.env.NEWSDATA_API_URL ?? 'https://api.example.com/news',
apiKey: process.env.NEWSDATA_API_KEY ?? '',
defaultCountry: 'us',
defaultCategory: 'top'
},
email: {
imapUser: process.env.IMAP_USER ?? '',
imapPass: process.env.IMAP_PASS ?? '',
imapHost: process.env.IMAP_HOST ?? '',
imapPort: Number(process.env.IMAP_PORT) ?? 993, smtpServ: process.env.SMTP_SERVICE ?? '',
smtpUser: process.env.SMTP_USER ?? '',
smtpPass: process.env.SMTP_PASS ?? '',
smtpHost: process.env.SMTP_HOST ?? '',
smtpPort: Number(process.env.SMTP_PORT) ?? 587,
}
} as const;
`Usage
$3
`typescript
// Read a file
const result = await fileService.readFile({ uri: '/path/to/file.txt' });// List directory contents
const contents = await fileService.readFolder({ uri: '/path/to/directory' });
`$3
`typescript
// Add a memory
await memoryService.addMemory({
topic: 'meeting',
note: 'Discuss project timeline'
});// Retrieve memories
const memories = await memoryService.getMemory({ topic: 'meeting' });
`$3
`typescript
// Get news by category
const news = await newsService.getNews({
country: 'us',
category: 'technology'
});// Get news with pagination
const nextPage = await newsService.getNews({
page: 'next_page_token'
});
`$3
`typescript
// Read emails
const emails = await emailService.readEmails({
folder: 'INBOX',
noEmails: 5
});// Send email
const result = await emailService.sendEmail({
receiver: "john.doe@example.com",
subject: "email subject",
textContent: "email content in text",
htmlContent: "
email content in html
"
});
`Error Handling
The application uses a centralized error handling system. All errors are handled consistently and return a standardized response format:
`typescript
{
content: [{
type: 'text',
text: 'Error message with context'
}]
}
`Development
1. Build the project:
`bash
npm run build
`2. Run with inspector for debugging:
`bash
npm run inspector
`3. Create executable (requires Bun):
`bash
npm run create_executable
`Project Structure
`
src/
├── config/ # Configuration files
├── services/ # Service implementations
├── strategies/ # Strategy patterns for file reading
├── types/ # TypeScript type definitions
└── utils/ # Utility functions
`Dependencies
$3
- @modelcontextprotocol/sdk: ^1.11.3
- imap: ^0.8.19
- mailparser: ^3.7.3
- nodemailer: ^7.0.3
- pdftoimg-js: ^0.2.2
- zod: ^3.24.4$3
- @types/imap: ^0.8.42
- @types/mailparser: ^3.4.6
- @types/node: ^22.15.18
- @types/nodemailer: ^6.4.17
- typescript: ^5.8.3Contributing
1. Fork the repository
2. Create your feature branch (
git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add some amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)This project is licensed under the MIT License - see the LICENSE file for details.
- Model Context Protocol for the MCP specification
- TypeScript for type safety
- Zod for runtime type checking