Star Wars API & MCP server (swapi.build)

build.swapi由 swapi.build 發布官方發布者v2.15.0更新於 Oct 29, 2026

Free Star Wars MCP server (SWAPI): people, films, planets, species, starships, vehicles. No API key.

已驗證Streamable HTTP可網頁執行網頁搜尋與抓取知識與記憶

概覽

AI 產生的概覽

免費的唯讀遠端 MCP 伺服器,提供星戰 I–VI 部電影資料:可依名稱搜尋、列出、依 id 取得,或隨機取人物、電影、星球、物種、星艦、載具。

可以做什麼
  • 依名稱或片名搜尋人物、電影、星球、物種、星艦和載具,並可用欄位投影精簡結果
  • 依記錄 id 取得單一實體,可在同一次呼叫中展開 homeworld、species 等關聯記錄
  • 列出某一資源類型的全部實體,或隨機回傳一個實體用於示範和問答
  • 以 MCP 資源形式讀取相同記錄,並使用 character_profile 提示詞
適用情境
適合需要星戰資料做示範、問答、範例應用或測試 MCP 用戶端的場合,且希望使用免註冊的免費端點。它不是現實世界或即時資訊的來源。
執行需求
需要一個遠端 Streamable HTTP 端點;不需 API 金鑰、帳號或本機執行環境。不支援舊版 HTTP+SSE 傳輸。伺服器閒置時會縮容至零,首次連線失敗時可能需要重試一次。
安裝前請注意
唯讀且無需驗證,不寫入資料也不索取密鑰。資料僅涵蓋 I–VI 六部電影。列表回應可能很大(全部人物約 38 KB),建議優先使用搜尋或欄位投影。網站另提供實驗性的瀏覽器端 WebMCP 工具,回傳格式不同。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Star Wars API & MCP server (swapi.build),將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Web executable,透過 Streamable HTTP。 遠端服務在工作區中設定後即可從網頁執行環境執行。

交給代理程式安裝

把這段提示詞貼上到 Claude Code、Codex、Cursor 等代理程式,或 SourceWeft 對話中。代理程式會讀取該伺服器的安裝指南,先向你展示發布者、端點和登入方式,經你同意後再把它新增到你的客戶端。金鑰不會寫進任何命令。

閱讀 https://sourceweft.com/mcp/build.swapi%2Fstar-wars/install.md,並按其中說明把這個 MCP 伺服器接入我的客戶端。修改任何設定之前,先告訴我它的發布者、端點和登入方式,等我確認。不要把 API 金鑰寫進命令或我會提交的檔案;問我金鑰應從哪裡取得。

檢視代理程式所依據的安裝指南

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。

{
  "mcpServers": {
    "star-wars-api-swapi-build": {
      "type": "http",
      "url": "https://swapi.build/mcp"
    }
  }
}

README

SWAPI.build

A free, open-source Star Wars API serving data about People, Films, Planets, Species, Starships, and Vehicles. Built with Quarkus and GraalVM for instant startup, minimal memory footprint, and out-of-the-box performance.

Inspired by the original SWAPI (created by Paul Hallett, maintained by Juriy Bura), this project was born out of the need for a Star Wars API built to stay up for live demos. If you've ever had a live demo break because a third-party API went down, you know why this exists.

Quick Start

Prerequisites: Java 25 and Maven (or use the included Maven Wrapper).

bash
cd swapi-app./mvnw quarkus:dev

The API and frontend will be available at http://localhost:5432.

API Endpoints

Base path: /api

ResourceList AllBy IDRandomSearch
PeopleGET /api/peopleGET /api/people/:idGET /api/people/randomGET /api/people?search=name
FilmsGET /api/filmsGET /api/films/:idGET /api/films/randomGET /api/films?search=title
PlanetsGET /api/planetsGET /api/planets/:idGET /api/planets/randomGET /api/planets?search=name
SpeciesGET /api/speciesGET /api/species/:idGET /api/species/randomGET /api/species?search=name
StarshipsGET /api/starshipsGET /api/starships/:idGET /api/starships/randomGET /api/starships?search=name
VehiclesGET /api/vehiclesGET /api/vehicles/:idGET /api/vehicles/randomGET /api/vehicles?search=name

Ids are the record ids from each entity's url field (for films, 1 = A New Hope). Successful responses return 200; unknown or non-numeric ids return 404.

GET /api/stats returns anonymous request counts per route (for example /api/people/{id} or /mcp) and per group (REST API, MCP, pages, SEO, other) for the last 24 hours (?period=24h, per hour), 7 days (default, per day; &granularity=hour for hourly) or 30 days (?period=30d, per day), each with the window before it for comparison, plus server response times per route and per group under performance (requests, mean, min, max, standard deviation and approximate p50/p95/p99 in milliseconds, network excluded). They are counted with no IP address or client details. The /stats page shows the same numbers with filters, a trend chart, a ranking and a Performance section.

All responses are JSON. Example:

bash
curl http://localhost:5432/api/people/1

OpenAPI

The full API contract is served at /openapi.json (OpenAPI 3.x, generated from the code — always in sync). The documentation page renders from it, including a "try it" for every endpoint. Generate a client with, e.g.:

npx @openapitools/openapi-generator-cli generate -i https://swapi.build/openapi.json -g typescript-fetch

MCP Server

swapi.build is also a remote MCP server over Streamable HTTP. Any Streamable HTTP client works: the stateless 2026-07-28 revision sends self-contained requests, and earlier revisions negotiate a session through initialize — both are served on the same endpoint. The legacy HTTP+SSE transport (2024-11-05) is not supported. First-party, read-only, no authentication:

https://swapi.build/mcp

Full setup guides: swapi.build/docs/mcp

ToolArgumentsReturns
sw_listresource, optional fieldsAll entities of a resource
sw_getresource, id, optional expandOne entity by id
sw_randomresourceA random entity
sw_searchresource, query, optional fieldsName/title substring match

resource is one of PEOPLE, FILMS, PLANETS, SPECIES, STARSHIPS, VEHICLES. Ids are the record ids from each entity's url field (for FILMS, 1 = A New Hope). expand names relations to embed in the same call (["homeworld", "species"], or ["*"]); fields projects each entity (["name"] gives a compact index; url always stays).

Since 2.13.0 the records are also MCP resources: swapi://people (an index) and swapi://people/1 (the sw_get text), for the six types, plus the templates swapi://<type>/{id}. The server prompt character_profile takes a character name.

Caching: Quarkiverse MCP Server 2.0.0 emits the required ttlMs: 0 and cacheScope: "public" fields on stateless discovery and tool-list responses. Zero TTL means immediately stale; no positive freshness period is configured. Its cache hints apply to discovery, list methods and resources/read, not tools/call. Tool-result caching is not enabled, including for sw_random. REST/edge caching is a separate mechanism.

Claude Code
bash
claude mcp add --transport http swapi-build https://swapi.build/mcp

Or share via .mcp.json at the repo root:

json
{  "mcpServers": {    "swapi-build": { "type": "http", "url": "https://swapi.build/mcp" }  }}

Verify: claude mcp list → swapi-build ✔ Connected.

Claude Desktop & claude.ai

Settings → Connectors → Add custom connector → name swapi-build, URL https://swapi.build/mcp. No authentication needed. Verify in any chat via the + menu → Connectors.

OpenAI Codex
bash
codex mcp add swapi-build --url https://swapi.build/mcp

Or in ~/.codex/config.toml (shared by CLI, IDE extension and ChatGPT desktop):

toml
[mcp_servers.swapi-build]url = "https://swapi.build/mcp"

Verify: codex mcp list.

GitHub Copilot (VS Code)

.vscode/mcp.json (top-level key is servers):

json
{  "servers": {    "swapi-build": { "type": "http", "url": "https://swapi.build/mcp" }  }}

Or Command Palette → MCP: Add Server. Verify via the Configure Tools button in Copilot Chat. On Business/Enterprise, the "MCP servers in Copilot" org policy must be enabled.

IBM Bob

~/.bob/settings/mcp_settings.json (global) or .bob/mcp.json (project):

json
{  "mcpServers": {    "swapi-build": {      "type": "streamable-http",      "url": "https://swapi.build/mcp",      "disabled": false    }  }}

Or Bob panel → MCP tab → Edit Global MCP. Bob detects the tools automatically.

The server scales to zero when idle — if the very first connection attempt fails, retry once (the native binary starts in tens of milliseconds; the platform may take a bit longer to provision the container; subsequent calls are fast, whether your client is stateless or session-based).

WebMCP in the browser (experimental)

The website exposes sw_list, sw_get, sw_search and sw_random through WebMCP. Names and required arguments match the remote MCP tools, including uppercase resource names; the optional expand and fields arguments exist only on the remote server. Each browser tool updates the visible explorer and returns complete records in a JSON result with ok, data, resource and path. The browser result envelope differs from the remote MCP transport.

Use a compatible browser with WebMCP enabled and the document.modelContext API. The setup and demonstration guide explains the inspector, example calls and cancellation behavior. When the API is unavailable, the site works normally. No model API key or AI runtime is embedded in the site. The JavaScript is bundled by Quinoa and runs in the browser, including when served by the Quarkus native executable.

Client examples

Project Structure

swapi-app/  src/main/    java/com/eldermoraes/     # Backend (Quarkus + Jakarta REST)      film/                   # Film model, service, resource      people/                 # People model, service, resource      planet/                 # Planet model, service, resource      specie/                 # Specie model, service, resource      starship/               # Starship model, service, resource      vehicle/                # Vehicle model, service, resource      mcp/                    # MCP server tools (sw_list, sw_get, sw_random, sw_search)      SWObject.java           # Base model class      SWService.java          # Service interface      ApiResource.java        # Root /api endpoint      ApplicationPath.java    # Jakarta REST base path (/api)    resources/      data/                   # Static JSON data files      application.properties  # Quarkus configuration    webui/                    # Frontend (TypeScript + Vite)      src/        api.ts                # API client with request management        main.ts               # SPA router        pages/                # Page renderers (home, resource, docs, mcp, about, privacy, terms)        json-highlight.ts     # JSON syntax highlighting for result panels        style.css             # Site styles        types.ts              # TypeScript interfaces for API resources        constants.ts          # Shared resource metadata        utils.ts              # Shared utilities (escapeHtml)  src/test/    java/com/eldermoraes/     # Regression suite (REST contracts, MCP tools, forwarded headers)

Each backend domain (film, people, planet, etc.) follows the same pattern:

  • Model (e.g., Film.java): POJO with @RegisterForReflection for native image support
  • Service (e.g., FilmService.java): loads data from JSON at startup, caches in memory
  • Resource (e.g., FilmResource.java): Jakarta REST controller with @RunOnVirtualThread

Build

bash
cd swapi-app
# Development mode (live reload)./mvnw quarkus:dev
# Production JAR./mvnw packagejava -jar target/quarkus-app/quarkus-run.jar
# Native executable (requires GraalVM or container build)./mvnw package -Dnative./mvnw package -Dnative -Dquarkus.native.container-build=true

The frontend is automatically built and bundled by Quinoa during the Maven build. No separate npm step is needed.

Deployment

The app runs as a native (GraalVM/Mandrel) executable on a self-hosted server on Oracle Cloud, managed by systemd behind Caddy (TLS via Let's Encrypt). DNS is managed on Cloudflare (DNS-only records pointing to the server). Publishing a GitHub Release runs .github/workflows/native-binary.yml: test suite, native build attached to the Release, a manual approval, then the install on the server over SSH and the production probes. The runbook is docs/DEPLOY.md.

Tech Stack

  • Runtime: Quarkus 3.33 on Java 25 with Virtual Threads
  • MCP server: Quarkiverse MCP Server — Streamable HTTP, stateless and session-based clients
  • Serialization: Jakarta REST + JSON-B
  • Native image: GraalVM via Mandrel builder
  • Frontend: TypeScript + Vite, served by Quinoa

Contributing

Pull requests are always welcome. Whether it's fixing a bug, improving the docs, or adding new features, jump in and help make the best Star Wars API in the galaxy even better.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/my-change)
  3. Make your changes (with tests) and run the suite: cd swapi-app && ./mvnw test
  4. Commit and push
  5. Open a Pull Request

Changelog and releases

Release history lives in CHANGELOG.md. Tagged releases are on the Releases page. The version served in /openapi.json (info.version) is always the latest released version. The release process itself is documented in docs/RELEASE.md.

Credits

  • Original SWAPI by Paul Hallett, maintained by Juriy Bura
  • Star Wars data from community-driven sources such as Wookieepedia
  • All Star Wars content and imagery are property of Lucasfilm Ltd. and Disney. This project is not affiliated with or endorsed by Lucasfilm or Disney.

License

Licensed under the Apache License 2.0. The website also publishes a Privacy Policy and Terms of Use.

來源:README.md,提交 4cada15

工具

4

sw_get

Get Star Wars entity by id

Gets one Star Wars entity by numeric record id and returns it as a JSON object. Take the id from the end of an entity's url field (from sw_search, sw_list or a relation URL). Ids are record ids, not episode numbers: FILMS id 1 is A New Hope (Episode IV). An unknown id returns a tool error, e.g. 'No films found with id 99'. Pass expand to get related records in the same call, e.g. ["homeworld", "species"]; name only the relations you need; * on a film can pass 50 KB.

輸入參數id必填expandresource必填

sw_list

List Star Wars resources

Lists every entity of one Star Wars resource type as a JSON array (Episodes I-VI data). Responses are large (all 82 PEOPLE, about 38 KB); to find a single entity, prefer sw_search, then sw_get; for a compact index pass fields, e.g. ["name"] (about 5 KB).

輸入參數fieldsresource必填

sw_random

Random Star Wars entity

Returns one random Star Wars entity of the given resource type as a JSON object. Each call can return a different entity, so it is not idempotent. Useful for demos and quizzes; to fetch a specific entity use sw_search or sw_get.

輸入參數resource必填

版本歷史

6
  1. v2.15.0最新Oct 29, 2026
  2. v2.8.2Oct 26, 2026
  3. v2.8.1Oct 20, 2026
  4. v2.8.0Oct 20, 2026
  5. v2.5.2Oct 19, 2026
  6. v2.5.1Sep 16, 2026

評分

已滿足適用檢查項的 100%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通必需25 分
  • 已宣告認證方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

其他 Swapi 整合