township-mcp-server / README.md
puseletso55's picture
Update README.md
0863cd1 verified

A newer version of the Gradio SDK is available: 5.38.2

Upgrade
metadata
license: apache-2.0
title: Township MCP Server
sdk: gradio
emoji: πŸ“Š
colorFrom: indigo
colorTo: blue
pinned: true
thumbnail: >-
  https://cdn-uploads.huggingface.co/production/uploads/63cd800cf712328861ab1888/moNs1-VgoT_YpJ49ZW7AL.webp
short_description: JSON-RPC API and UI for registering and discovering township
sdk_version: 5.36.2
  • βœ… Project description
  • βœ… Installation steps
  • βœ… API usage with examples
  • βœ… Gradio testing instructions
  • βœ… Contribution, License, and Contact info

βœ… README.md

# 🧠 Township MCP Server

This project provides a **Multimodal Command Protocol (MCP) Server** for township businesses, allowing clients to:

- βœ… Register township businesses (name, phone, location, etc.)
- βœ… Query nearby businesses using geolocation
- βœ… Interact with the server via:
  - JSON-RPC API (via Flask)
  - Web UI (via Gradio)

> πŸ”— Live Gradio Demo: [puseletso55/township-mcp-server](https://puseletso55-township-mcp-server.hf.space)

---

## πŸ“¦ Project Structure

township-mcp-server/ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ app.py # Main Flask + Gradio server β”‚ β”œβ”€β”€ api/ β”‚ β”‚ └── client_predict.py # CLI tool to send JSON-RPC requests β”‚ β”œβ”€β”€ utils/ β”‚ β”‚ └── api_logger.py # Logs API interactions β”œβ”€β”€ requirements.txt β”œβ”€β”€ README.md


---

## βš™οΈ Installation

1. **Clone the repository**
```bash
git clone https://github.com/puseletso55/township-mcp-server.git
cd township-mcp-server
  1. Create a virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Set up environment variables (optional but recommended)
export MONGO_URI="your_mongo_connection_uri"

πŸš€ Run the Server

python src/app.py

πŸ§ͺ Sample JSON-RPC Requests

βœ… Register a Business

{
  "jsonrpc": "2.0",
  "method": "registerBusiness",
  "params": {
    "name": "Test Business",
    "description": "Test Description",
    "address": "123 Test St",
    "phone": "1234567890",
    "latitude": "26.2041",
    "longitude": "28.0473"
  },
  "id": 1
}

βœ… Get Nearby Businesses

{
  "jsonrpc": "2.0",
  "method": "getNearbyBusinesses",
  "params": {
    "latitude": "26.2041",
    "longitude": "28.0473",
    "radius_km": 10
  },
  "id": 2
}

πŸ” Send these in POST to /run/predict as:

{
  "data": ["<your JSON-RPC string>"]
}

πŸ–₯️ CLI Tool Example

Run the command-line client with input:

python src/api/client_predict.py "{\"jsonrpc\": \"2.0\", \"method\": \"getNearbyBusinesses\", \"params\": {\"latitude\": \"26.2041\", \"longitude\": \"28.0473\"}, \"id\": 1}"

🧾 Logging

API interactions are logged with timestamps and colors using colorlog for better visibility.


πŸ“‹ Requirements

All dependencies are listed in requirements.txt. Install using:

pip install -r requirements.txt

🀝 Contributing

  1. Fork this repo
  2. Create your feature branch: git checkout -b feature/my-feature
  3. Commit your changes: git commit -m "Add feature"
  4. Push to the branch: git push origin feature/my-feature
  5. Submit a pull request πŸš€

πŸ“„ License

MIT License Β© 2025 Puseletso Daniel Mafisa


πŸ“¬ Contact

  • Developer: Puseletso Mafisa
  • Company: Mafisa Tech Affiliate Pty Ltd
  • Email: [email protected]

Made in πŸ‡ΏπŸ‡¦ to empower township businesses.


---