dhealth_intelligence
v1.1.2-alpha
Published
A Model Context Protocol (MCP) server that provides intelligent tools for file operations, memory management, news retrieval, and email processing.
Readme
dHealth Intelligence
A Model Context Protocol (MCP) server that provides intelligent tools for file operations, memory management, news retrieval, and email processing.
Features
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
Prerequisites
- Node.js (v16 or higher)
- npm or yarn
- TypeScript
- Bun (optional, for creating executables)
Installation
- Clone the repository:
git clone https://github.com/dhealthproject/dhealth-intelligence.git
cd dhealth-intelligence- Install dependencies:
npm install- Set up environment variables:
# Memory file path (optional, defaults to memory.json in project root)
MEM_PATH=/path/to/memory.json
# News API configuration
NEWSDATA_API_URL=https://api.example.com/news
NEWSDATA_API_KEY=your_api_key_here
# Email configuration
EMAIL_HOST=your_imap_host
EMAIL_USER=your_email
EMAIL_PASSWORD=your_passwordConfiguration
The application uses a centralized configuration system. You can modify the default values in src/config/index.ts:
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
File Operations
// 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' });Memory Management
// Add a memory
await memoryService.addMemory({
topic: 'meeting',
note: 'Discuss project timeline'
});
// Retrieve memories
const memories = await memoryService.getMemory({ topic: 'meeting' });News Retrieval
// 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'
});Email Processing
// Read emails
const emails = await emailService.readEmails({
folder: 'INBOX',
noEmails: 5
});
// Send email
const result = await emailService.sendEmail({
receiver: "[email protected]",
subject: "email subject",
textContent: "email content in text",
htmlContent: "<p>email content in html</p>"
});Error Handling
The application uses a centralized error handling system. All errors are handled consistently and return a standardized response format:
{
content: [{
type: 'text',
text: 'Error message with context'
}]
}Development
- Build the project:
npm run build- Run with inspector for debugging:
npm run inspector- Create executable (requires Bun):
npm run create_executableProject Structure
src/
├── config/ # Configuration files
├── services/ # Service implementations
├── strategies/ # Strategy patterns for file reading
├── types/ # TypeScript type definitions
└── utils/ # Utility functionsDependencies
Main Dependencies
- @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
Development Dependencies
- @types/imap: ^0.8.42
- @types/mailparser: ^3.4.6
- @types/node: ^22.15.18
- @types/nodemailer: ^6.4.17
- typescript: ^5.8.3
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Model Context Protocol for the MCP specification
- TypeScript for type safety
- Zod for runtime type checking
