Skip to content

feat: add create_project and create_iteration_field methods to projects_write#2232

Open
SamMorrowDrums wants to merge 1 commit intomainfrom
sammorrowdrums/add-project-create-tools
Open

feat: add create_project and create_iteration_field methods to projects_write#2232
SamMorrowDrums wants to merge 1 commit intomainfrom
sammorrowdrums/add-project-create-tools

Conversation

@SamMorrowDrums
Copy link
Copy Markdown
Collaborator

Summary

Adds two new methods to the consolidated projects_write tool enabling programmatic sprint planning:

  • create_project — creates a new GitHub ProjectsV2 for a user or org; returns project ID, number, title, URL
  • create_iteration_field — adds an iteration field to an existing project with configurable duration and start date; optionally accepts named iteration definitions

Supersedes #2227 and #1864. Closes #1854.

Why

Enables AI agents to automate sprint planning workflows — creating projects and defining iteration cycles — without manual GitHub UI interaction.

Design decisions

  • Consolidated into projects_write rather than standalone tools, following the strong existing pattern (projects_list, projects_get, projects_write all use method dispatch)
  • iterations is optional — the basic use case is creating a field with start_date + duration; specific named sprints are a power-user option
  • project_number is conditionally required — not needed for create_project (you don't have one yet); validated per-method in the handler
  • owner_type auto-detects for create_iteration_field (uses detectOwnerType like other methods); required for create_project (no project to probe)

What changed

  • pkg/github/projects.go — Added createProject and createIterationField helper functions; added method constants; expanded ProjectsWrite schema and handler with two new methods; added getOwnerNodeID and getProjectNodeID helpers; local GraphQL input types for iteration configuration
  • pkg/github/projects_test.go — Updated required fields assertion for schema change
  • pkg/github/projects_v2_test.go — Unit tests for both methods (success with iterations, success without iterations, missing owner_type error)
  • pkg/github/__toolsnaps__/projects_write.snap — Updated schema snapshot
  • README.md — Auto-generated docs updated

MCP impact

  • Existing tool modified (new methods added)

Security / limits

  • Auth / permissions considered — both methods require the project write scope

CI fixes from #2227

  • Fixed gosec G115 integer overflow (intint32) with explicit casts and //nolint comments (iteration durations are small day counts)

Lint & tests

  • script/lint — 0 issues
  • script/test — all passing
  • script/generate-docs — README up to date

Co-authored-by: João Doria de Souza hi@joao.work

@SamMorrowDrums SamMorrowDrums requested a review from a team as a code owner March 17, 2026 13:55
Copilot AI review requested due to automatic review settings March 17, 2026 13:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds sprint-planning support to the consolidated projects_write tool by introducing new method-dispatched operations for creating ProjectsV2 projects and configuring iteration fields.

Changes:

  • Expanded projects_write tool schema/handler to support create_project and create_iteration_field.
  • Added helper functions and local GraphQL input types to implement the new ProjectsV2 mutations.
  • Added/updated unit tests, tool snapshot, and generated README tool docs for the schema changes.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
pkg/github/projects.go Adds the two new projects_write methods, helper functions, and schema/docs updates in the tool definition.
pkg/github/projects_test.go Updates schema-required-fields assertion to reflect method-conditional requirements.
pkg/github/projects_v2_test.go Adds unit tests covering the new method behavior paths.
pkg/github/toolsnaps/projects_write.snap Updates the snapshot to match the expanded projects_write input schema.
README.md Updates autogenerated tool documentation for the new parameters/methods.
Comments suppressed due to low confidence (2)

pkg/github/projects.go:1694

  • getProjectNodeID discards the *github.Response from GetUserProject, so the HTTP response body is never closed. Please capture the response and defer resp.Body.Close() to avoid leaking connections.
	project, _, err := client.Projects.GetUserProject(ctx, owner, projectNumber)
	if err != nil {
		return "", err
	}
	return project.GetNodeID(), nil

pkg/github/projects.go:1650

  • createIterationField returns MarshalledTextResult of a GraphQL struct without JSON tags, so output fields will be "ID", "Name", "Configuration", etc. This is inconsistent with the rest of the tool outputs that use json tags and snake_case keys. Consider mapping to an explicit response type with stable JSON field names (e.g. id, name, configuration) before marshaling.

	return MarshalledTextResult(updateMutation.UpdateProjectV2Field.ProjectV2Field.ProjectV2IterationField), nil, nil

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +1683 to +1690
project, _, err := client.Projects.GetOrganizationProject(ctx, owner, projectNumber)
if err != nil {
return "", err
}
return project.GetNodeID(), nil
}

project, _, err := client.Projects.GetUserProject(ctx, owner, projectNumber)
type ProjectV2IterationFieldConfigurationInput struct {
Duration githubv4.Int `json:"duration"`
StartDate githubv4.Date `json:"startDate"`
Iterations *[]ProjectV2IterationFieldIterationInput `json:"iterations"`
Comment on lines +1616 to +1620
for _, item := range rawIterations {
iterMap, ok := item.(map[string]any)
if !ok {
continue
}
return utils.NewToolResultError(fmt.Sprintf("failed to create project: %v", err)), nil, nil
}

return MarshalledTextResult(mutation.CreateProjectV2.ProjectV2), nil, nil
…ts_write

Adds two new methods to the consolidated projects_write tool:
- create_project: creates a new GitHub ProjectsV2 for a user or org
- create_iteration_field: adds an iteration field to an existing project

Changes addressing review feedback:
- Validate owner_type is exactly 'user' or 'org' in create_project
- Use resolveProjectNodeID (GraphQL) instead of getProjectNodeID (REST)
  to avoid HTTP response body leaks
- Add omitempty to Iterations JSON tag
- Rename iterations item field startDate to start_date for consistency
- Validate iteration elements instead of silently skipping invalid ones
- Use explicit response structs with snake_case JSON tags
- Add test for auto-detected owner_type in create_iteration_field
- Use stubExporters() in test deps for nil-safety

Co-authored-by: João Doria de Souza <jdoria@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SamMorrowDrums SamMorrowDrums force-pushed the sammorrowdrums/add-project-create-tools branch from 7a6b929 to 8298307 Compare April 7, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Support for GitHub Projects v2 Iteration Fields

2 participants