Documentation
¶
Overview ¶
Package tasks provides a client for managing Google Tasks.
This package wraps the Google Tasks API (tasks/v1) and provides functionality for:
- Managing task lists (list, get, create, update, delete)
- Managing tasks (list, get, create, update, delete, complete, move)
- Filtering tasks by due date and completion status
- Creating subtasks and organizing task hierarchies
The client supports both CLI and MCP server modes, with multi-account authentication through the unified Google OAuth2 system.
Authentication ¶
The client uses the same OAuth2 token system as other Google services (Gmail, Calendar, etc.). Tokens are stored per-account in the user's cache directory and provide access to:
- Google Tasks (read/write)
For HTTP/SSE transports: OAuth is handled automatically by the MCP client. For STDIO transport: Tokens are loaded from the file system (~/.cache/inboxfewer/).
Example Usage ¶
// Create a client for the default account
client, err := tasks.NewClient(ctx)
if err != nil {
log.Fatal(err)
}
// List all task lists
lists, err := client.ListTaskLists()
if err != nil {
log.Fatal(err)
}
// Create a new task
task, err := client.CreateTask(lists[0].ID, tasks.TaskInput{
Title: "Complete project",
Notes: "Finish implementation and testing",
Due: time.Now().AddDate(0, 0, 7), // Due in 7 days
})
if err != nil {
log.Fatal(err)
}
// Complete a task
completed, err := client.CompleteTask(lists[0].ID, task.ID)
if err != nil {
log.Fatal(err)
}
Index ¶
- func HasToken() bool
- func HasTokenForAccount(account string) bool
- func HasTokenForAccountWithProvider(account string, provider google.TokenProvider) bool
- type Client
- func NewClient(ctx context.Context) (*Client, error)
- func NewClientForAccount(ctx context.Context, account string) (*Client, error)
- func NewClientForAccountWithProvider(ctx context.Context, account string, tokenProvider google.TokenProvider) (*Client, error)
- func NewClientWithProvider(ctx context.Context, provider google.TokenProvider) (*Client, error)
- func (c *Client) Account() string
- func (c *Client) ClearCompletedTasks(taskListID string) error
- func (c *Client) CompleteTask(taskListID, taskID string) (*Task, error)
- func (c *Client) CreateTask(taskListID string, input TaskInput) (*Task, error)
- func (c *Client) CreateTaskList(title string) (*TaskList, error)
- func (c *Client) DeleteTask(taskListID, taskID string) error
- func (c *Client) DeleteTaskList(taskListID string) error
- func (c *Client) GetTask(taskListID, taskID string) (*Task, error)
- func (c *Client) GetTaskList(taskListID string) (*TaskList, error)
- func (c *Client) ListTaskLists() ([]TaskList, error)
- func (c *Client) ListTasks(taskListID string, showCompleted bool, dueMin, dueMax time.Time) ([]Task, error)
- func (c *Client) MoveTask(taskListID, taskID string, parent, previous string) (*Task, error)
- func (c *Client) UpdateTask(taskListID, taskID string, input TaskInput) (*Task, error)
- func (c *Client) UpdateTaskList(taskListID, title string) (*TaskList, error)
- type Link
- type Task
- type TaskInput
- type TaskList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasToken ¶
func HasToken() bool
HasToken checks if a valid OAuth token exists for the default account
func HasTokenForAccount ¶
HasTokenForAccount checks if a valid OAuth token exists for the specified account
func HasTokenForAccountWithProvider ¶ added in v0.0.27
func HasTokenForAccountWithProvider(account string, provider google.TokenProvider) bool
HasTokenForAccountWithProvider checks if a valid OAuth token exists for the specified account
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Google Tasks service
func NewClient ¶
NewClient creates a new Tasks client with OAuth2 authentication for the default account For CLI usage, it will prompt for auth code via stdin if no token exists For MCP usage, it will return an error if no token exists
func NewClientForAccount ¶
NewClientForAccount creates a new Tasks client with OAuth2 authentication for a specific account Uses the default file-based token provider for backward compatibility
func NewClientForAccountWithProvider ¶ added in v0.0.27
func NewClientForAccountWithProvider(ctx context.Context, account string, tokenProvider google.TokenProvider) (*Client, error)
NewClientForAccountWithProvider creates a new Tasks client with OAuth2 authentication for a specific account The OAuth token is retrieved from the provided token provider
func NewClientWithProvider ¶ added in v0.0.27
NewClientWithProvider creates a new Tasks client with OAuth2 authentication for the default account using the provided token provider
func (*Client) ClearCompletedTasks ¶
ClearCompletedTasks clears all completed tasks from a task list
func (*Client) CompleteTask ¶
CompleteTask marks a task as completed
func (*Client) CreateTask ¶
CreateTask creates a new task
func (*Client) CreateTaskList ¶
CreateTaskList creates a new task list
func (*Client) DeleteTask ¶
DeleteTask deletes a task
func (*Client) DeleteTaskList ¶
DeleteTaskList deletes a task list
func (*Client) GetTaskList ¶
GetTaskList retrieves a specific task list by ID
func (*Client) ListTaskLists ¶
ListTaskLists lists all task lists for the authenticated user
func (*Client) ListTasks ¶
func (c *Client) ListTasks(taskListID string, showCompleted bool, dueMin, dueMax time.Time) ([]Task, error)
ListTasks lists tasks in a task list Options: - showCompleted: if true, includes completed tasks - dueMin: only tasks with due date after this time - dueMax: only tasks with due date before this time
func (*Client) UpdateTask ¶
UpdateTask updates an existing task
type Task ¶
type Task struct {
ID string
Title string
Notes string
Status string // "needsAction" or "completed"
Due time.Time
Completed time.Time
Parent string // Parent task ID for subtasks
Position string // Position in the list
Links []Link // Related links
}
Task represents a Google Tasks task