- Set up a SpinAI project with MCP integration
- Configure GitHub actions through MCP
- Create an agent that can interact with GitHub’s API
- Test your agent with a basic repository creation task
Getting Started
1. Create a New SpinAI Project
💡 Quick Start: If you want to skip the manual setup, you can select the GitHub MCP Agent
template instead of the default template. This will automatically configure everything we’ll cover in steps 1-5, and you can jump straight to running the agent (don’t forget to setup your environment variables, though!).
2. Set Up Environment Variables
Create a.env
file in your project root and add the following variables:
- An OpenAI API key for running the agent. We’re using OpenAI’s model in this example, but you can swap it for any model supported by Vercel’s AI SDK.
-
A GitHub personal access token. To create one:
- Go to GitHub’s Developer Settings
- Click “Generate new token (classic)”
- Give your token a descriptive name (e.g., “SpinAI GitHub Assistant”)
- Select only the permissions you’re comfortable with. For this example, you’ll need:
repo
access to create and manage repositoriesread:user
for basic profile information
- Copy the generated token (you won’t be able to see it again!)
- Paste it into your
.env
file as theGITHUB_TOKEN
value
.env
file to version control. It should belisted in your .gitignore
, but in case it’s not, make sure it is.
3. Set Up MCP Configuration
You’ll need to create an MCP configuration file to specify which MCP actions you want to use. There are two ways to do this: The easiest way is to use our CLI tool:mcp-config.ts
file with the GitHub MCP configuration.
NOTE: It’s highly recommended to keep your GITHUB_TOKEN in your .env
and either import it in your mcp-config.ts, or in the next step.
4. Set Up the Agent
Now we’ll set up our agent to use the MCP actions. Open yoursrc/index.ts
file and replace the boilerplate code with:
- We import the necessary functions from SpinAI and the OpenAI model from AI SDK
createActionsFromMcpConfig
translates our MCP configuration into SpinAI actions- We create an agent with those actions and instructions about its purpose
- Finally, we run the agent with a test command to create a repository
5. Run the Agent
Now you can run your agent:input
in your code to make the agent perform different GitHub tasks. For example: