gradio-mcp / app.py
smarttdev's picture
Create Gradio MCP server
5ecfb7e
import math
import gradio as gr
def compute_projectile_distance(initial_speed, angle):
"""
Calculate the horizontal distance traveled by a projectile.
Parameters:
initial_speed (float): Initial speed of the projectile in m/s
angle (float): Launch angle in degrees
Returns:
float: Horizontal distance traveled in meters
"""
# Convert angle from degrees to radians
angle_rad = math.radians(angle)
# Gravitational acceleration (m/s²)
g = 9.81
# Calculate the horizontal distance using the projectile motion formula:
# distance = (initial_speed² * sin(2*angle)) / g
distance = (initial_speed**2 * math.sin(2 * angle_rad)) / g
return distance
app = gr.Interface(
fn=compute_projectile_distance,
inputs=["number", "number"],
outputs="number",
title="Compute Projectile Distance",
description="Computes the theoretical horizontal distance a projectile travels for a given initial speed and angle."
)
#Initialiser l'application
app.launch(mcp_server=True, share=True)