Skip to main content
Glama

Charts Visualization MCP Server

by sakshi1x
bar_chart.py1.38 kB
# import altair as alt # from src.model.main import ChartInput, save_chart # import uuid # def create_bar_chart(input_data: ChartInput) -> str: # """Create a bar chart and return image URL.""" # chart_id = str(uuid.uuid4()) # data_dicts = [d.model_dump() for d in input_data.data] # chart = alt.Chart(alt.Data(values=data_dicts)).mark_bar().encode( # x=alt.X("label:N", title="Label"), # y=alt.Y("value:Q", title="Value"), # color=alt.value(input_data.color) # ).properties( # width=400, # height=300 # ) # return save_chart(chart, chart_id) import uuid from pathlib import Path import altair as alt from model.main import ChartInput OUTPUT_DIR = Path("static/charts") BASE_URL = "http://localhost:8000/static/charts" def create_bar_chart(chart_input: ChartInput) -> str: """Create a bar chart and return its URL.""" data = [{"label": item.label, "value": item.value} for item in chart_input.data] chart = alt.Chart(alt.Data(values=data)).mark_bar().encode( x="label:N", y="value:Q", color=alt.Color("label:N", scale=alt.Scale(scheme=chart_input.color)) ) chart_id = str(uuid.uuid4()) output_path = OUTPUT_DIR / f"{chart_id}.png" OUTPUT_DIR.mkdir(parents=True, exist_ok=True) chart.save(output_path, format="png") return f"{BASE_URL}/{chart_id}.png"

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sakshi1x/mcp_visualization'

If you have feedback or need assistance with the MCP directory API, please join our Discord server