Confluence init
This commit is contained in:
88
Libraries/Confluence/Pages/ConfluencePagesTools.cs
Normal file
88
Libraries/Confluence/Pages/ConfluencePagesTools.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using LazyBear.Confluence;
|
||||
using ModelContextProtocol.Server;
|
||||
|
||||
namespace LazyBear.Confluence.Pages;
|
||||
|
||||
[McpServerToolType]
|
||||
public sealed class ConfluencePagesTools(ConfluenceHttpClientProvider provider)
|
||||
{
|
||||
private readonly ConfluenceHttpClientProvider _provider = provider;
|
||||
|
||||
[McpServerTool, Description("Список страниц Confluence")]
|
||||
public async Task<string> ListPagesAsync(
|
||||
[Description("Пространство")] string? spaceKey = null,
|
||||
[Description("ID родитель")] string? parentId = null,
|
||||
[Description("Максимум")] int? limit = 20,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(spaceKey))
|
||||
{
|
||||
return "spaceKey не задан.";
|
||||
}
|
||||
|
||||
var resource = $"{spaceKey}/pages";
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, resource);
|
||||
|
||||
return $"Список страниц в {spaceKey}";
|
||||
}
|
||||
|
||||
[McpServerTool, Description("Получить страницу Confluence")]
|
||||
public async Task<string> GetPageAsync(
|
||||
[Description("ID страницы")] string pageId,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(pageId))
|
||||
{
|
||||
return "pageId не задан.";
|
||||
}
|
||||
|
||||
return $"Страница: {pageId}";
|
||||
}
|
||||
|
||||
[McpServerTool, Description("Создать страницу")]
|
||||
public async Task<string> CreatePageAsync(
|
||||
[Description("Заголовок")] string title,
|
||||
[Description("Контент")] string content,
|
||||
[Description("Пространство")] string spaceKey,
|
||||
[Description("ID родитель")] string? parentId = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(title))
|
||||
{
|
||||
return "title не задан.";
|
||||
}
|
||||
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, $"rest/api/content?typeName=page");
|
||||
|
||||
return $"Страница создана: {title}";
|
||||
}
|
||||
|
||||
[McpServerTool, Description("Обновить страницу")]
|
||||
public async Task<string> UpdatePageAsync(
|
||||
[Description("ID")] string id,
|
||||
[Description("Заголовок")] string? title = null,
|
||||
[Description("Контент")] string? content = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(id))
|
||||
{
|
||||
return "id не задан.";
|
||||
}
|
||||
|
||||
return $"Страница обновлена: {id}";
|
||||
}
|
||||
|
||||
[McpServerTool, Description("Удалить страницу")]
|
||||
public async Task<string> DeletePageAsync(
|
||||
[Description("ID страницы")] string pageId,
|
||||
[Description("Перманентно?")] bool? permanent = false,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(pageId))
|
||||
{
|
||||
return "pageId не задан.";
|
||||
}
|
||||
|
||||
return $"Страница удалена: {pageId}";
|
||||
}
|
||||
}
|
||||
17
Libraries/Confluence/Pages/find-files.ps1
Normal file
17
Libraries/Confluence/Pages/find-files.ps1
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.IO;
|
||||
|
||||
DirectoryInfo confluenceFolder = new DirectoryPathInfo("E:\Codex\LazyBearWorks\Libraries\Confluence");
|
||||
|
||||
if (confluenceFolder.Exists)
|
||||
{
|
||||
FileInfo[] files = confluenceFolder.GetFiles();
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
Console.WriteLine("Found file: " + file.FullName + " Size: " + file.Length + " bytes");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Confluence folder not found!");
|
||||
}
|
||||
Reference in New Issue
Block a user