Skip to main content
Glama
nawani-rohit

SpaceX MCP Server

by nawani-rohit
README.md
# ๐Ÿš€ SpaceX MCP Server

A lightweight **Model Context Protocol (MCP)** server that fetches public SpaceX launch data and exposes three analytics endpoints.

| `analysisType` value | What it returns |
| -------------------- | --------------- |
| `countByYear`        | Launch counts for every year from the first SpaceX flight to the most recent. |
| `successVsFailure`   | Total number of successful vs. failed launches. |
| `mostFrequentSite`   | Launch site used most often and its count. |

---

## ๐Ÿ“‚ Project Structure
```bash
spacex-mcp-server/
โ”œโ”€โ”€ analysis.py
โ”œโ”€โ”€ launch_data.py
โ”œโ”€โ”€ main.py
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ README.md
```
---

## โšก Quick Start

```bash
git clone https://github.com/nawani-rohit/MCP-Server.git
cd spacex-mcp-server

pip install -r requirements.txt
uvicorn main:app --reload --port 3000
````
---

## ๐ŸŽฏ API Endpoints

| Method | Path                     | Query Parameter                 | Description               |
| ------ | ------------------------ | ------------------------------- | ------------------------- |
| `GET`  | `/mcp/launches/analysis` | `analysisType=countByYear`      | Launch counts per year    |
|        |                          | `analysisType=successVsFailure` | Success vs failure totals |
|        |                          | `analysisType=mostFrequentSite` | Most-used launch site     |

---

## ๐Ÿงช Requests & Responses

> Replace `3000` if you run on a different port.

### 1๏ธโƒฃ Launch Count by Year

```bash
curl "http://localhost:3000/mcp/launches/analysis?analysisType=countByYear"
```

```json
{
  "2006": 1,
  "2007": 1,
  "2008": 2,
  "2009": 1,
  "2010": 2,
  "2011": 0,
  "2012": 2,
  "2013": 3,
  "2014": 6,
  "2015": 7,
  "2016": 9,
  "2017": 18,
  "2018": 21,
  "2019": 13,
  "2020": 25
}
```

### 2๏ธโƒฃ Successful vs Failed Launches

```bash
curl "http://localhost:3000/mcp/launches/analysis?analysisType=successVsFailure"
```

```json
{
  "successful_launches": 191,
  "failed_launches": 9
}
```

### 3๏ธโƒฃ Most Frequent Launch Site

```bash
curl "http://localhost:3000/mcp/launches/analysis?analysisType=mostFrequentSite"
```

```json
{
  "site": "CCAFS SLC 40",
  "launch_count": 52
}
```