Content
# .NET MCP Anycall Mobile Sample
This solution contains a Streamable HTTP MCP server and a Blazor Server chat/table app for Anycall mobile phone price lists.
## Projects
### DotNetMcpSseServer
- Hosts MCP tools at `/mcp` with bearer-token protection.
- Hosts REST APIs at `/api/phones`.
- Stores dated Anycall price snapshots in SQLite.
- Seeds the first SQLite snapshot from `Features/Api/anycall-mobile-data.json`.
- Imports pasted or uploaded Anycall plain text atomically: if parsing has fatal row errors, the selected date is not changed.
- Exports the selected snapshot to Excel.
### DotNetMcpBlazorSample
- Chat-first UI at `/`.
- Date-aware phone table at `/phones`.
- Plain-text snapshot import page at `/imports`.
- Uses REST for table/import/export workflows.
- Uses MCP tools for grounded chat facts, with optional Hugging Face wording through `HF_TOKEN`.
## Key Endpoints
- `GET /api/phones?date=yyyy-MM-dd`
- `GET /api/phones/search?brand=Apple&maxPrice=5000000&date=yyyy-MM-dd`
- `GET /api/phones/brands?date=yyyy-MM-dd`
- `GET /api/phones/snapshots`
- `POST /api/phones/snapshots/import-text`
- `POST /api/phones/import/text`
- `GET /api/phones/price-diff?fromDate=yyyy-MM-dd&toDate=yyyy-MM-dd`
- `GET /api/phones/export/excel?date=yyyy-MM-dd`
## MCP Tools
- `search_mobile_phones`
- `get_phone_by_brand`
- `get_phones_by_price_range`
- `list_brands`
- `get_cheapest_phones`
- `list_price_dates`
- `compare_mobile_phone_prices`
Most phone tools accept an optional `date` argument. Price comparison accepts optional `fromDate` and `toDate`; when omitted, it compares the latest two available snapshots.
## Configuration
Server SQLite database:
```json
{
"ConnectionStrings": {
"MobilePhones": "Data Source=Data/anycall-mobile.db"
}
}
```
Blazor MCP and Hugging Face settings:
```json
{
"McpServer": {
"Url": "http://localhost:5194/mcp",
"AuthToken": "my-super-secret-password-123"
},
"HuggingFace": {
"BaseUrl": "https://router.huggingface.co/v1/chat/completions",
"Model": "meta-llama/Llama-3.1-8B-Instruct"
}
}
```
Set `HF_TOKEN` or user secrets for Hugging Face. Do not commit `HuggingFace:ApiToken`.
## Run
```powershell
dotnet run --project DotNetMcpSseServer --launch-profile http
dotnet run --project DotNetMcpBlazorSample --launch-profile http
```
- API and Scalar docs: `http://localhost:5194`
- Blazor app: `http://localhost:5095`
## Test
```powershell
dotnet build DotNetMcpSample.sln
dotnet test DotNetMcpSample.Tests\DotNetMcpSample.Tests.csproj --no-build
```