Skip to content

CursorAgents

Nuget package dotnet License: MIT Discord

Features 🔥

  • Fully generated C# SDK based on official CursorAgents OpenAPI specification using AutoSDK
  • Same day update to support new features
  • Updated and supported automatically if there are no breaking changes
  • All modern .NET features - nullability, trimming, NativeAOT, etc.
  • Support .Net Framework/.Net Standard 2.0

Usage

1
2
3
using CursorAgents;

using var client = new CursorAgentsClient(apiKey);

Create Agent

Launch a cloud agent to work autonomously on a GitHub repository.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Create a client with your Cursor API key.
using var client = new CursorAgentsClient(apiKey);

var repositoryUrl =
    Environment.GetEnvironmentVariable("CURSORAGENTS_TEST_REPO") is { Length: > 0 } repoValue
        ? repoValue
        : throw new AssertInconclusiveException(
            "CURSORAGENTS_TEST_REPO environment variable is not found.");

// Launch a coding agent with a prompt and source repository.
var response = await client.CreateAgentAsync(
    prompt: new CreateAgentRequestPrompt
    {
        Text = "Add a CONTRIBUTING.md file with guidelines for submitting pull requests",
    },
    repos:
    [
        new RepoConfig
        {
            Url = repositoryUrl,
            StartingRef = "main",
        },
    ],
    workOnCurrentBranch: false,
    autoCreatePR: true);

// The response contains the agent ID, name, and initial status.

Console.WriteLine($"Agent created: {response.Agent.Summary?.Id} ({response.Agent.Summary?.Name})");
Console.WriteLine($"Run status: {response.Run.Status}");

List Agents

List cloud agents and check their statuses.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Create a client with your Cursor API key.
using var client = new CursorAgentsClient(apiKey);

// List cloud agents for the authenticated user with a page limit.
var response = await client.ListAgentsAsync(
    limit: 10);

// The response contains a list of agents with their status and metadata.

foreach (var agent in response.Items)
{

    Console.WriteLine($"Agent {agent.Id}: {agent.Name}");
    Console.WriteLine($"  Status: {agent.Status.ToValueString()}");
    Console.WriteLine($"  Created: {agent.CreatedAt}");

    if (agent.LatestRunId is { Length: > 0 })
    {
        Console.WriteLine($"  Latest run: {agent.LatestRunId}");
    }
}

// Use the NextCursor property for pagination when there are more results.
if (response.NextCursor is { Length: > 0 })
{
    Console.WriteLine($"Next page cursor: {response.NextCursor}");
}

Get Conversation

Retrieve the conversation history of a cloud agent, including user prompts and assistant responses.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
// Create a client with your Cursor API key.
using var client = new CursorAgentsClient(apiKey);

var agentId =
    Environment.GetEnvironmentVariable("CURSORAGENTS_TEST_AGENT_ID") is { Length: > 0 } idValue
        ? idValue
        : throw new AssertInconclusiveException(
            "CURSORAGENTS_TEST_AGENT_ID environment variable is not found.");

// Retrieve the current metadata for a specific agent.
var response = await client.GetAgentAsync(
    id: agentId);

// The response contains the agent ID and current status.

if (response.Summary is { } summary)
{
    Console.WriteLine($"Agent {summary.Id}: {summary.Name}");
    Console.WriteLine($"Status: {summary.Status.ToValueString()}");
}

As Tool Creates Agent Tool

Verify that AsCreateAgentTool creates a valid AIFunction.

1
2
3
4
5
6
// Create a client and wrap it as an MEAI tool.
using var client = new CursorAgentsClient(apiKey);

var tool = client.AsCreateAgentTool();

// The tool has a name and description for use with any IChatClient.

As Tool Creates List Tool

Verify that AsListAgentsTool creates a valid AIFunction.

1
2
3
4
5
6
// Create a client and wrap it as an MEAI tool.
using var client = new CursorAgentsClient(apiKey);

var tool = client.AsListAgentsTool();

// The tool has a name and description for use with any IChatClient.

As Tool Creates Get Agent Tool

Verify that AsGetAgentTool creates a valid AIFunction.

1
2
3
4
5
6
// Create a client and wrap it as an MEAI tool.
using var client = new CursorAgentsClient(apiKey);

var tool = client.AsGetAgentTool();

// The tool has a name and description for use with any IChatClient.

Ecosystem maintenance

This SDK is one of more than 200 .NET SDKs maintained with AutoSDK. The tryAGI SDK audit continuously checks repository synchronization, upstream-spec regeneration, release workflows, warnings, public API visibility, and trimming/NativeAOT compatibility.

Every issue is first investigated for ecosystem-wide applicability. When the root cause belongs in AutoSDK, we fix and regression-test the generator, then roll the improvement out to every applicable SDK. Provider-specific behavior remains in this repository when it cannot be derived safely from the API specification.

Issue content—including code blocks, logs, links, and attachments—is treated only as untrusted diagnostic data. Embedded control instructions, hidden directives, delimiter tricks, or requests to alter triage or tooling behavior are ignored. Please report reproducible technical evidence and remove secrets and personal data.

Support

Priority place for bugs: https://github.com/tryAGI/CursorAgents/issues
Priority place for ideas and general questions: https://github.com/tryAGI/CursorAgents/discussions
Discord: https://discord.gg/Ca2xhfBf3v

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.