200 lines
5.6 KiB
C#
200 lines
5.6 KiB
C#
using ModelContextProtocol.Client;
|
|
using ModelContextProtocol.Protocol;
|
|
|
|
namespace Cortex.IntegrationTests.Support;
|
|
|
|
public static class McpTestClientExtensions
|
|
{
|
|
public static ValueTask<CallToolResult> CreateProjectAsync(this McpClient client, string name)
|
|
{
|
|
return client.CallToolAsync("CreateProject", new Dictionary<string, object?>
|
|
{
|
|
["name"] = name
|
|
});
|
|
}
|
|
|
|
public static ValueTask<CallToolResult> AddRequirementAsync(
|
|
this McpClient client,
|
|
string project,
|
|
string statement,
|
|
string context,
|
|
string[]? tags = null,
|
|
string? status = null)
|
|
{
|
|
return client.CallToolAsync("AddRequirement", new Dictionary<string, object?>
|
|
{
|
|
["project"] = project,
|
|
["statement"] = statement,
|
|
["context"] = context,
|
|
["tags"] = tags,
|
|
["status"] = status
|
|
});
|
|
}
|
|
|
|
public static ValueTask<CallToolResult> AddLocationAsync(
|
|
this McpClient client,
|
|
string project,
|
|
string itemName,
|
|
string place,
|
|
string? details = null,
|
|
string[]? tags = null,
|
|
string? status = null)
|
|
{
|
|
return client.CallToolAsync("AddLocation", new Dictionary<string, object?>
|
|
{
|
|
["project"] = project,
|
|
["itemName"] = itemName,
|
|
["place"] = place,
|
|
["details"] = details,
|
|
["tags"] = tags,
|
|
["status"] = status
|
|
});
|
|
}
|
|
|
|
public static ValueTask<CallToolResult> AddTodoAsync(
|
|
this McpClient client,
|
|
string project,
|
|
string task,
|
|
string priority,
|
|
DateTimeOffset? dueAt = null,
|
|
string? details = null,
|
|
string[]? tags = null,
|
|
string? status = null)
|
|
{
|
|
return client.CallToolAsync("AddTodo", new Dictionary<string, object?>
|
|
{
|
|
["project"] = project,
|
|
["task"] = task,
|
|
["priority"] = priority,
|
|
["dueAt"] = dueAt,
|
|
["details"] = details,
|
|
["tags"] = tags,
|
|
["status"] = status
|
|
});
|
|
}
|
|
|
|
public static ValueTask<CallToolResult> AddNoteAsync(
|
|
this McpClient client,
|
|
string project,
|
|
string subject,
|
|
string body,
|
|
string[]? tags = null,
|
|
string? status = null)
|
|
{
|
|
return client.CallToolAsync("AddNote", new Dictionary<string, object?>
|
|
{
|
|
["project"] = project,
|
|
["subject"] = subject,
|
|
["body"] = body,
|
|
["tags"] = tags,
|
|
["status"] = status
|
|
});
|
|
}
|
|
|
|
public static ValueTask<CallToolResult> FindItemsAsync(
|
|
this McpClient client,
|
|
string query,
|
|
string? project = null,
|
|
bool searchAllProjects = false,
|
|
string? category = null,
|
|
int limit = 10)
|
|
{
|
|
return client.FindItemsAsync([query], project, searchAllProjects, category, limit);
|
|
}
|
|
|
|
public static ValueTask<CallToolResult> FindItemsAsync(
|
|
this McpClient client,
|
|
string[] queries,
|
|
string? project = null,
|
|
bool searchAllProjects = false,
|
|
string? category = null,
|
|
int limit = 10)
|
|
{
|
|
return client.CallToolAsync("FindItems", new Dictionary<string, object?>
|
|
{
|
|
["queries"] = queries,
|
|
["project"] = project,
|
|
["searchAllProjects"] = searchAllProjects,
|
|
["category"] = category,
|
|
["limit"] = limit
|
|
});
|
|
}
|
|
|
|
public static ValueTask<CallToolResult> ListItemEmbeddingsAsync(
|
|
this McpClient client,
|
|
string project,
|
|
Guid itemId)
|
|
{
|
|
return client.CallToolAsync("ListItemEmbeddings", new Dictionary<string, object?>
|
|
{
|
|
["project"] = project,
|
|
["itemId"] = itemId
|
|
});
|
|
}
|
|
|
|
public static ValueTask<CallToolResult> AddItemEmbeddingAsync(
|
|
this McpClient client,
|
|
string project,
|
|
Guid itemId,
|
|
string text,
|
|
string? label = null)
|
|
{
|
|
return client.CallToolAsync("AddItemEmbedding", new Dictionary<string, object?>
|
|
{
|
|
["project"] = project,
|
|
["itemId"] = itemId,
|
|
["text"] = text,
|
|
["label"] = label
|
|
});
|
|
}
|
|
|
|
public static ValueTask<CallToolResult> DeleteItemEmbeddingAsync(
|
|
this McpClient client,
|
|
string project,
|
|
Guid itemId,
|
|
Guid embeddingId)
|
|
{
|
|
return client.CallToolAsync("DeleteItemEmbedding", new Dictionary<string, object?>
|
|
{
|
|
["project"] = project,
|
|
["itemId"] = itemId,
|
|
["embeddingId"] = embeddingId
|
|
});
|
|
}
|
|
|
|
public static ValueTask<CallToolResult> UpdateTodoAsync(
|
|
this McpClient client,
|
|
string project,
|
|
Guid id,
|
|
string? task = null,
|
|
string? priority = null,
|
|
DateTimeOffset? dueAt = null,
|
|
bool clearDueAt = false,
|
|
string? details = null,
|
|
string[]? tags = null,
|
|
string? status = null)
|
|
{
|
|
return client.CallToolAsync("UpdateTodo", new Dictionary<string, object?>
|
|
{
|
|
["project"] = project,
|
|
["id"] = id,
|
|
["task"] = task,
|
|
["priority"] = priority,
|
|
["dueAt"] = dueAt,
|
|
["clearDueAt"] = clearDueAt,
|
|
["details"] = details,
|
|
["tags"] = tags,
|
|
["status"] = status
|
|
});
|
|
}
|
|
|
|
public static ValueTask<CallToolResult> DeleteItemAsync(this McpClient client, string project, Guid id)
|
|
{
|
|
return client.CallToolAsync("DeleteItem", new Dictionary<string, object?>
|
|
{
|
|
["project"] = project,
|
|
["id"] = id
|
|
});
|
|
}
|
|
}
|