This document provides example GraphQL queries used by the MCP server and demonstrates how to interact with GitHub Projects.
query($owner: String!, $repo: String!) {
repository(owner: $owner, name: $repo) {
projectsV2(first: 20) {
nodes {
id
number
title
shortDescription
closed
public
createdAt
updatedAt
}
}
}
}query($owner: String!) {
organization(login: $owner) {
projectsV2(first: 20) {
nodes {
id
number
title
shortDescription
closed
public
createdAt
updatedAt
}
}
}
}query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
projectV2(number: $number) {
id
number
title
shortDescription
readme
closed
public
createdAt
updatedAt
fields(first: 20) {
nodes {
... on ProjectV2Field {
id
name
dataType
}
... on ProjectV2SingleSelectField {
id
name
dataType
options {
id
name
}
}
... on ProjectV2IterationField {
id
name
dataType
}
}
}
}
}
}query($projectId: ID!, $first: Int!) {
node(id: $projectId) {
... on ProjectV2 {
items(first: $first) {
nodes {
id
createdAt
updatedAt
content {
... on Issue {
id
number
title
state
url
}
... on PullRequest {
id
number
title
state
url
}
... on DraftIssue {
id
title
}
}
fieldValues(first: 20) {
nodes {
... on ProjectV2ItemFieldTextValue {
field {
... on ProjectV2Field {
id
name
}
}
text
}
... on ProjectV2ItemFieldNumberValue {
field {
... on ProjectV2Field {
id
name
}
}
number
}
... on ProjectV2ItemFieldDateValue {
field {
... on ProjectV2Field {
id
name
}
}
date
}
... on ProjectV2ItemFieldSingleSelectValue {
field {
... on ProjectV2SingleSelectField {
id
name
}
}
name
}
}
}
}
}
}
}
}mutation($projectId: ID!, $contentId: ID!) {
addProjectV2ItemById(input: {projectId: $projectId, contentId: $contentId}) {
item {
id
createdAt
}
}
}mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: ProjectV2FieldValue!) {
updateProjectV2ItemFieldValue(
input: {
projectId: $projectId
itemId: $itemId
fieldId: $fieldId
value: $value
}
) {
projectV2Item {
id
}
}
}GitHub Projects support various field types:
- Text: Plain text fields
- Number: Numeric values
- Date: Date values
- Single Select: Dropdown with predefined options
- Iteration: Sprint/iteration tracking
- Milestone: GitHub milestones
- Labels: GitHub labels
- Assignees: User assignments
GitHub's GraphQL API uses global node IDs. Here's how to find them:
- Project ID: Returned when listing projects
- Issue/PR ID: Available in issue/PR GraphQL queries
- Field ID: Listed in project field queries
- Item ID: Returned when listing project items
Common errors and solutions:
- Authentication Error: Ensure your GitHub token has the required scopes
- Not Found: Verify the owner, repo, and project number
- Permission Denied: Check if the token has access to private repositories/projects
- Invalid Field Value: Ensure the value matches the field type
GitHub GraphQL API has rate limits:
- Authenticated requests: 5,000 points per hour
- Each query consumes points based on complexity
- Monitor the
X-RateLimit-*headers in responses