File size: 8,558 Bytes
fb139a0
 
 
 
 
 
 
f3b720b
0b81900
 
f3b720b
0b81900
f3b720b
 
 
004218a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f3b720b
 
 
 
 
 
 
 
8f3faab
f3b720b
 
 
 
8f3faab
f3b720b
 
 
 
 
 
 
 
 
 
 
 
 
 
8f3faab
 
 
 
f3b720b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8f3faab
 
 
 
 
 
 
 
 
 
 
 
f3b720b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8f3faab
f3b720b
 
8f3faab
 
f3b720b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8f3faab
 
 
 
 
 
 
 
f3b720b
 
 
 
 
 
 
 
 
 
 
 
 
 
8f3faab
 
f3b720b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
---
license: mit
title: SUMIT SERVER MCP
sdk: docker
emoji: πŸš€
colorFrom: yellow
colorTo: green
short_description: THIS IS MCP SERVER.
---

# Tatva MCP Server πŸš€

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.13+](https://img.shields.io/badge/python-3.13+-blue.svg)](https://www.python.org/downloads/)
[![FastMCP](https://img.shields.io/badge/FastMCP-2.12.4+-green.svg)](https://github.com/jlowin/fastmcp)
<!-- SAFE-MCP Security Badge -->
<a href="https://api.astha.ai/astha/v1/report/ASM-2025-11-21-QORZJFIAE" target="_blank" rel="noopener noreferrer" style="display:inline-flex;align-items:center;gap:8px;padding:8px 16px;background:#ffffff;border:2px solid #2563eb;border-radius:8px;text-decoration:none;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;transition:transform 0.2s,box-shadow 0.2s;" onmouseover="this.style.transform='translateY(-2px)';this.style.boxShadow='0 4px 12px rgba(0,0,0,0.15)';" onmouseout="this.style.transform='translateY(0)';this.style.boxShadow='none';" title="View detailed security report">
  <svg width="24" height="24" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z" stroke="#3b82f6" stroke-width="6" fill="none"/>
    <line x1="30" y1="35" x2="70" y2="35" stroke="#3b82f6" stroke-width="5" stroke-linecap="round"/>
    <line x1="30" y1="50" x2="70" y2="50" stroke="#3b82f6" stroke-width="5" stroke-linecap="round"/>
    <line x1="30" y1="65" x2="70" y2="65" stroke="#3b82f6" stroke-width="5" stroke-linecap="round"/>
  </svg>
  <div style="display:flex;flex-direction:column;gap:2px;">
    <div style="font-size:10px;font-weight:600;color:#6b7280;text-transform:uppercase;letter-spacing:0.5px;">SAFE-MCP Verified</div>
    <div style="font-size:14px;font-weight:700;color:#111827;">222/300 β€’ LOW</div>
    <div style="font-size:8px;color:#9ca3af;">Valid: Nov 2025 - Feb 2026</div>
  </div>
</a>
<!-- End SAFE-MCP Badge -->

A Model Context Protocol (MCP) server that provides intelligent access to content from the Tatva website (tatva.sumityadav.com.np). This server enables AI assistants to fetch, analyze, and interact with blog posts, pages, and resources from the Tatva platform.

## ✨ Features

- **Content Fetching**: Retrieve content from any page on the Tatva website
- **Blog Post Management**: Access and search through all blog posts
- **Smart Search**: Find posts by keywords or filter by year
- **Task Management**: Store and retrieve tasks using Turso (libSQL) database
- **Resource Access**: Direct access to homepage, about page, and specific posts
- **Analysis Tools**: Built-in prompts for post analysis and comparison
- **Docker Support**: Easy deployment with containerization
- **Hugging Face Spaces Ready**: Optimized for HF Spaces deployment
- **Environment Configuration**: Automatic loading of environment variables from `.env` file

## πŸ› οΈ Available Tools

### Content Retrieval
- `get_page_content(url)` - Fetch content from any specific URL
- `get_homepage_content()` - Get homepage content
- `get_about_page()` - Get about page content
- `get_post_content(post_path)` - Get specific blog post content

### Blog Management
- `get_all_posts_summary()` - List all available blog posts
- `search_posts_by_keyword(keyword)` - Search posts by keyword
- `get_posts_by_year(year)` - Filter posts by publication year

### Task Management
- `put_task_to_db(task, time_date)` - Add a task to the database with date and time
- `get_task_from_db(today_date)` - Retrieve all tasks for a specific date

### Resources
- `tatva://homepage` - Homepage resource
- `tatva://about` - About page resource
- `tatva://posts/{post_path}` - Specific post resource

### Analysis Prompts
- `analyze_post_prompt(post_path)` - Generate analysis prompt for a post
- `compare_posts_prompt(post1, post2)` - Generate comparison prompt for two posts

## πŸš€ Quick Start

### Prerequisites
- Python 3.13+
- [uv](https://github.com/astral-sh/uv) package manager

### Installation

1. **Clone the repository**
   ```bash
   git clone https://github.com/yourusername/sumit-mcp-server.git
   cd sumit-mcp-server
   ```

2. **Install dependencies**
   ```bash
   uv sync
   ```

3. **Configure environment variables**
   
   Create a `.env` file in the project root with your Turso credentials:
   ```bash
   TURSO_AUTH_TOKEN=your_turso_auth_token
   TURSO_DATABASE_URL=your_turso_database_url
   PORT=7860
   ```
   
   The server will automatically load these from the `.env` file.

4. **Run the server**
   ```bash
   uv run server.py
   ```

The server will start on `http://localhost:7860` with the MCP endpoint at `/api/mcp/`.

### Docker Deployment

1. **Build the image**
   ```bash
   docker build -t tatva-mcp-server .
   ```

2. **Run the container**
   ```bash
   docker run -p 7860:7860 tatva-mcp-server
   ```

## πŸ“– Usage Examples

### Fetching Content
```python
# Get homepage content
homepage = get_homepage_content()

# Get a specific blog post
post = get_post_content("2025/09/22/advance_scanner/")

# Search for posts about AI
ai_posts = search_posts_by_keyword("AI")
```

### Using with MCP Clients
The server exposes MCP tools that can be used by compatible AI assistants and clients. Connect to the server endpoint and use the available tools for content retrieval and analysis.

## πŸ—οΈ Project Structure

```
sumit-mcp-server/
β”œβ”€β”€ server.py          # Main MCP server implementation
β”œβ”€β”€ pyproject.toml     # Project configuration and dependencies
β”œβ”€β”€ Dockerfile         # Container configuration
β”œβ”€β”€ README.md          # This file
β”œβ”€β”€ .env               # Environment variables (create with your Turso credentials)
β”œβ”€β”€ .gitignore         # Git ignore rules
└── uv.lock           # Dependency lock file
```

## πŸ”§ Configuration

The server is configured to work with:
- **Base URL**: `https://tatva.sumityadav.com.np`
- **Port**: 7860 (configurable via `PORT` environment variable)
- **Transport**: Server-Sent Events (SSE)
- **Path**: `/api/mcp/`

## 🌐 Deployment

### Hugging Face Spaces
This server is optimized for deployment on Hugging Face Spaces:
- Uses port 7860 (HF Spaces standard)
- Includes proper Docker configuration
- Supports SSE transport for real-time communication

### Environment Variables

The server automatically loads environment variables from a `.env` file in the project root. Create a `.env` file with:

- `TURSO_AUTH_TOKEN`: Authentication token for Turso database (required)
- `TURSO_DATABASE_URL`: Database URL for Turso (libSQL) connection (required)
- `PORT`: Server port (default: 7860, optional)

**Note**: The `.env` file is automatically ignored by git to keep your credentials secure. You can also set these as system environment variables if preferred.

## πŸ“ API Reference

### Tools

| Tool | Description | Parameters |
|------|-------------|------------|
| `get_page_content` | Fetch content from any URL | `url: str` |
| `get_homepage_content` | Get homepage content | None |
| `get_about_page` | Get about page content | None |
| `get_post_content` | Get specific post content | `post_path: str` |
| `get_all_posts_summary` | List all posts | None |
| `search_posts_by_keyword` | Search posts | `keyword: str` |
| `get_posts_by_year` | Filter by year | `year: str` |
| `put_task_to_db` | Add task to database | `task: str`, `time_date: str` |
| `get_task_from_db` | Get tasks for date | `today_date: str` |

### Resources

| Resource | Description |
|----------|-------------|
| `tatva://homepage` | Homepage content |
| `tatva://about` | About page content |
| `tatva://posts/{path}` | Specific post content |

## 🀝 Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## πŸ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## πŸ”— Links

- **Tatva Website**: [tatva.sumityadav.com.np](https://tatva.sumityadav.com.np)
- **FastMCP**: [GitHub Repository](https://github.com/jlowin/fastmcp)
- **Model Context Protocol**: [Official Documentation](https://modelcontextprotocol.io/)

## πŸ“ž Support

For support, questions, or contributions, please open an issue on GitHub or contact the maintainer.

---

**Made with ❀️ for the Tatva Sumit**