by johnpapa
MCP Server for the SWAPI Star Wars API, demonstrating how an MCP server interacts with APIs.
mcp-starwars is an MCP (Model Context Protocol) server designed to interact with the SWAPI Star Wars API. Its primary goal is to showcase how an MCP server can be effectively used to communicate with and retrieve data from external APIs. All data utilized by this MCP server is sourced directly from the SWAPI documentation.
mcp-starwars can be installed and used in several ways:
settings.json
file.npx @smithery/cli install @johnpapa/mcp-starwars --client claude
command.npx @modelcontextprotocol/inspector node build/index.js
..vscode/mcp.json
for a specific repository or add settings to your VS Code User Settings JSON for all repositories. After setup, refresh the server list in GitHub Copilot and use the "π οΈ" button to see available tools. You can then ask questions that invoke these tools.Q: What is the main goal of this project? A: The main goal is to demonstrate how an MCP server can be used to interact with APIs, specifically the SWAPI Star Wars API.
Q: Where does the data for this MCP server come from? A: All data used by this MCP server is fetched directly from the SWAPI documentation (https://swapi.dev).
Q: How can I clear the cache?
A: You can use the clear_cache
tool, optionally specifying an endpoint to clear or leaving it empty to clear all.
Q: How can I see cache statistics?
A: Use the get_cache_stats
tool to view cache hit/miss statistics, size, and performance metrics.
Q: Can I use this with GitHub Copilot? A: Yes, you can configure the MCP server to be discoverable by GitHub Copilot in VS Code Insiders and then use its tools within Copilot Agent mode.
Features β’ Tools β’ Setup β’ Configuring an MCP Host
MCP Server for the SWAPI Star Wars API. The main goal of the project is to show how an MCP server can be used to interact with APIs.
Note: All data used by this MCP server is fetched from the SWAPI documentation](https://swapi.dev).
get_people
π§βπ€βπ§page
(optional number): The page number to retrieve (defaults to 1)search
(optional string): Name or partial name to search forfetchAllPages
(optional boolean): Whether to automatically fetch all pages of results (defaults to true)get_person_by_id
π€id
(string or number): The unique identifier of the characterget_planets
πͺpage
(optional number): The page number to retrieve (defaults to 1)search
(optional string): Planet name or partial name to search forfetchAllPages
(optional boolean): Whether to automatically fetch all pages of results (defaults to true)get_planet_by_id
πid
(string or number): The unique identifier of the planetget_films
π¬page
(optional number): The page number to retrieve (defaults to 1)search
(optional string): Film title or partial title to search forfetchAllPages
(optional boolean): Whether to automatically fetch all pages of results (defaults to true)get_film_by_id
π½οΈid
(string or number): The unique identifier of the filmget_species_list
π½page
(optional number): The page number to retrieve (defaults to 1)search
(optional string): Species name or partial name to search forfetchAllPages
(optional boolean): Whether to automatically fetch all pages of results (defaults to true)get_species_by_id
π§¬id
(string or number): The unique identifier of the speciesget_vehicles
πpage
(optional number): The page number to retrieve (defaults to 1)search
(optional string): Vehicle name or partial name to search forfetchAllPages
(optional boolean): Whether to automatically fetch all pages of results (defaults to true)get_vehicle_by_id
πid
(string or number): The unique identifier of the vehicleget_starships
πpage
(optional number): The page number to retrieve (defaults to 1)search
(optional string): Starship name or partial name to search forfetchAllPages
(optional boolean): Whether to automatically fetch all pages of results (defaults to true)get_starship_by_id
πΈid
(string or number): The unique identifier of the starshipclear_cache
π§Ήendpoint
(optional string): Specific endpoint to clear from cache. Leave empty to clear all.get_cache_stats
πFor the quickest installation, click on one of the VS Code installation buttons at the top of this README.
You can install the Star Wars MCP server manually using the following commands:
For VS Code Stable:
code --add-mcp '{"name":"starwars","command":"npx","args":["-y","@johnpapa/mcp-starwars"],"env":{}}'
For VS Code Insiders:
code-insiders --add-mcp '{"name":"starwars","command":"npx","args":["-y","@johnpapa/mcp-starwars"],"env":{}}'
"mcp": {
"servers": {
"starwars": {
"command": "npx",
"args": ["-y", "@johnpapa/mcp-starwars"],
"env": {}
}
}
},
"chat.mcp.discovery.enabled": true
To install Star Wars MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @johnpapa/mcp-starwars --client claude
If you'd like to run MCP Inspector locally to test the server, follow these steps:
Clone this repository:
git clone https://github.com/johnpapa/-mcp-starwars
Install the required dependencies and build the project.
npm install
npm run build
(Optional) To try out the server using MCP Inspector run the following command:
# Start the MCP Inspector
npx @modelcontextprotocol/inspector node build/index.js
Visit the MCP Inspector URL shown in the console in your browser. Change Arguments
to dist/index.js
and select Connect
. Select List Tools
to see the available tools.
Note: If you already have the MCP server enabled with Claude Desktop, add
chat.mcp.discovery.enabled: true
in your VS Code settings and it will discover existing MCP server lists.
If you want to associate the MCP server with a specific repo, create a .vscode/mcp.json
file with this content:
{
"inputs": [],
"servers": {
"mcp-starwars": {
"command": "npx",
// "command": "node",
"args": [
"-y",
"@johnpapa/mcp-starwars"
// "_git/mcp-starwars/dist/index.js"
],
"env": {}
}
}
}
If you want to associate the MCP server with all repos, add the following to your VS Code User Settings JSON:
"mcp": {
"servers": {
"mcp-starwars": {
"command": "npx",
// "command": "node",
"args": [
"-y",
"@johnpapa/mcp-starwars"
// "/Users/papa/_git/mcp-starwars/dist/index.js"
// "_git/mcp-starwars/dist/index.js"
],
"env": {}
}
}
}
"chat.mcp.discovery.enabled": true,
Now that the mcp server is discoverable, open GitHub Copilot and select the Agent
mode (not Chat
or Edits
).
Select the "refresh" button in the Copilot chat text field to refresh the server list.
Select the "π οΈ" button to see all the possible tools, including the ones from this repo.
Put a question in the chat that would naturally invoke one of the tools, for example:
How do I set my VS Code accent colors?
Note: If you see "Sorry, the response was filtered by the Responsible AI Service. Please rephrase your prompt and try again.", try running it again or rephrasing the prompt.
Please log in to share your review and rating for this MCP.