File size: 1,813 Bytes
264bb5c 3081c81 264bb5c 3081c81 74c8d32 264bb5c 3081c81 74c8d32 3081c81 74c8d32 264bb5c 3081c81 |
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 |
import gradio as gr
from tools import get_coords_from_address, calculate_distance
# --- Tools ---
geocoding_interface = gr.Interface(
fn=get_coords_from_address,
inputs=[
gr.Textbox(label="Address", placeholder="e.g., 1600 Amphitheatre Parkway, Mountain View, CA")
],
outputs=[
gr.Textbox(label="Coordinates (Lat, Lon)")
],
title="Address to Coordinates",
description="A tool to get the latitude and longitude for a given street address."
)
distance_interface = gr.Interface(
fn=calculate_distance,
inputs=[
gr.Number(label="Latitude Point A"),
gr.Number(label="Longitude Point A"),
gr.Number(label="Latitude Point B"),
gr.Number(label="Longitude Point B"),
gr.Radio(["km", "miles"], label="Unit", value="km")
],
outputs=[
gr.Textbox(label="Distance")
],
title="Distance Calculator",
description="A tool to calculate the distance between two geographic points."
)
# --- About Tab ---
with gr.Blocks() as about_tab:
gr.Markdown("""
# π Geocalc MCP Server
Welcome to the Geocalc MCP server. This application provides a collection of tools for geographic calculations.
This server is designed to be used by AI models (like LLMs) to perform geo-related tasks.
## Available Tools
- **Address Geocoding**: Converts a physical address into latitude and longitude coordinates.
Use the tabs above to navigate to the desired tool.
""")
# --- Assemble the Tabbed Interface ---
demo = gr.TabbedInterface(
[about_tab, geocoding_interface, distance_interface],
["About", "Address Geocoding", "Distance Calculator"],
title="π Geocalc MCP Server"
)
# --- Launch the Server ---
if __name__ == "__main__":
demo.launch(mcp_server=True, debug=True)
|