split each MCP server into tools/resources/prompts modules
This commit is contained in:
49
mcp_servers/passenger/resources.py
Normal file
49
mcp_servers/passenger/resources.py
Normal file
@@ -0,0 +1,49 @@
|
||||
"""Resources for the passenger MCP server."""
|
||||
|
||||
import json
|
||||
|
||||
from mcp_servers.data.scenarios.manager import scenario_manager
|
||||
from mcp_servers.passenger.server import mcp
|
||||
|
||||
|
||||
@mcp.resource("ops://flights/{flight_id}/manifest")
|
||||
def flight_manifest(flight_id: str) -> str:
|
||||
"""Passenger manifest summary for a flight.
|
||||
|
||||
Returns: flight_id, passenger count, count by MP status tier,
|
||||
special needs count, connection count.
|
||||
Summary-level — no PII exposed through this resource.
|
||||
"""
|
||||
flight = None
|
||||
for f in scenario_manager.flights:
|
||||
if f.flight_id == flight_id:
|
||||
flight = f
|
||||
break
|
||||
|
||||
if not flight:
|
||||
return json.dumps({"error": f"Flight {flight_id} not found"})
|
||||
|
||||
pax_on_flight = [
|
||||
p for p in scenario_manager.passengers
|
||||
if p.flight_id == flight_id
|
||||
]
|
||||
|
||||
status_counts = {}
|
||||
special_needs_count = 0
|
||||
connection_count = 0
|
||||
|
||||
for p in pax_on_flight:
|
||||
status = p.mileage_plus_status.value
|
||||
status_counts[status] = status_counts.get(status, 0) + 1
|
||||
if p.special_needs:
|
||||
special_needs_count += 1
|
||||
if p.connection_flight:
|
||||
connection_count += 1
|
||||
|
||||
return json.dumps({
|
||||
"flight_id": flight_id,
|
||||
"total_passengers": flight.passenger_count,
|
||||
"by_status": status_counts,
|
||||
"special_needs_count": special_needs_count,
|
||||
"connection_count": connection_count,
|
||||
})
|
||||
Reference in New Issue
Block a user