-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMcpTool.cs
More file actions
64 lines (55 loc) · 2.11 KB
/
McpTool.cs
File metadata and controls
64 lines (55 loc) · 2.11 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// The Sisk Framework source code
// Copyright (c) 2024- PROJECT PRINCIPIUM and all Sisk contributors
//
// The code below is licensed under the MIT license as
// of the date of its publication, available at
//
// File name: McpTool.cs
// Repository: https://github.com/sisk-http/core
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LightJson.Schema;
namespace Sisk.ModelContextProtocol;
/// <summary>
/// Represents a tool that can be hosted and executed by an MCP server.
/// </summary>
public sealed class McpTool {
/// <summary>
/// Gets the unique name of the tool.
/// </summary>
public string Name { get; }
/// <summary>
/// Gets the display title of the tool. If null, the <see cref="Name"/> will be used.
/// </summary>
public string? Title { get; }
/// <summary>
/// Gets a description of what the tool does.
/// </summary>
public string Description { get; }
/// <summary>
/// Gets the JSON schema that defines the expected input arguments for the tool.
/// </summary>
public JsonSchema Schema { get; }
/// <summary>
/// Gets or sets the handler function that will be executed when the tool is invoked.
/// </summary>
public McpToolHandler ExecuteAsync { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="McpTool"/> class.
/// </summary>
/// <param name="name">The unique name of the tool.</param>
/// <param name="description">A description of what the tool does.</param>
/// <param name="schema">The JSON schema defining the tool's input arguments.</param>
/// <param name="executionHandler">The handler function that will be executed when the tool is invoked.</param>
/// <param name="title">The optional display title of the tool.</param>
public McpTool ( string name, string description, JsonSchema schema, McpToolHandler executionHandler, string? title = null ) {
Name = name;
Title = title;
Description = description;
Schema = schema;
ExecuteAsync = executionHandler;
}
}