mcpls_core/mcp/
tools.rs

1//! MCP tool parameter definitions.
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6/// Parameters for the `get_hover` tool.
7#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
8pub struct HoverParams {
9    /// Absolute path to the file.
10    pub file_path: String,
11    /// Line number (1-based).
12    pub line: u32,
13    /// Character/column number (1-based).
14    pub character: u32,
15}
16
17/// Parameters for the `get_definition` tool.
18#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
19pub struct DefinitionParams {
20    /// Absolute path to the file.
21    pub file_path: String,
22    /// Line number (1-based).
23    pub line: u32,
24    /// Character/column number (1-based).
25    pub character: u32,
26}
27
28/// Parameters for the `get_references` tool.
29#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
30pub struct ReferencesParams {
31    /// Absolute path to the file.
32    pub file_path: String,
33    /// Line number (1-based).
34    pub line: u32,
35    /// Character/column number (1-based).
36    pub character: u32,
37    /// Whether to include the declaration in the results.
38    #[serde(default)]
39    pub include_declaration: bool,
40}
41
42/// Parameters for the `get_diagnostics` tool.
43#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
44pub struct DiagnosticsParams {
45    /// Absolute path to the file.
46    pub file_path: String,
47}
48
49/// Parameters for the `rename_symbol` tool.
50#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
51pub struct RenameParams {
52    /// Absolute path to the file.
53    pub file_path: String,
54    /// Line number (1-based).
55    pub line: u32,
56    /// Character/column number (1-based).
57    pub character: u32,
58    /// New name for the symbol.
59    pub new_name: String,
60}
61
62/// Parameters for the `get_completions` tool.
63#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
64pub struct CompletionsParams {
65    /// Absolute path to the file.
66    pub file_path: String,
67    /// Line number (1-based).
68    pub line: u32,
69    /// Character/column number (1-based).
70    pub character: u32,
71    /// Optional trigger character.
72    pub trigger: Option<String>,
73}
74
75/// Parameters for the `get_document_symbols` tool.
76#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
77pub struct DocumentSymbolsParams {
78    /// Absolute path to the file.
79    pub file_path: String,
80}
81
82/// Parameters for the `format_document` tool.
83#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
84pub struct FormatDocumentParams {
85    /// Absolute path to the file.
86    pub file_path: String,
87    /// Tab size for formatting.
88    #[serde(default = "default_tab_size")]
89    pub tab_size: u32,
90    /// Whether to use spaces instead of tabs.
91    #[serde(default = "default_insert_spaces")]
92    pub insert_spaces: bool,
93}
94
95const fn default_tab_size() -> u32 {
96    4
97}
98
99const fn default_insert_spaces() -> bool {
100    true
101}
102
103/// Parameters for the `workspace_symbol_search` tool.
104#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
105pub struct WorkspaceSymbolParams {
106    /// Search query for symbol names (supports partial matching).
107    pub query: String,
108    /// Optional filter by symbol kind (function, class, variable, etc.).
109    #[serde(skip_serializing_if = "Option::is_none")]
110    pub kind_filter: Option<String>,
111    /// Maximum results to return (default: 100).
112    #[serde(default = "default_max_results")]
113    pub limit: u32,
114}
115
116const fn default_max_results() -> u32 {
117    100
118}
119
120/// Parameters for the `get_code_actions` tool.
121#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
122pub struct CodeActionsParams {
123    /// Absolute path to the file.
124    pub file_path: String,
125    /// Start line (1-based).
126    pub start_line: u32,
127    /// Start character (1-based).
128    pub start_character: u32,
129    /// End line (1-based).
130    pub end_line: u32,
131    /// End character (1-based).
132    pub end_character: u32,
133    /// Optional filter by action kind (quickfix, refactor, source, etc.).
134    #[serde(skip_serializing_if = "Option::is_none")]
135    pub kind_filter: Option<String>,
136}
137
138/// Parameters for the `prepare_call_hierarchy` tool.
139#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
140pub struct CallHierarchyPrepareParams {
141    /// Absolute path to the file.
142    pub file_path: String,
143    /// Line number (1-based).
144    pub line: u32,
145    /// Character/column number (1-based).
146    pub character: u32,
147}
148
149/// Parameters for the `get_incoming_calls` and `get_outgoing_calls` tools.
150#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
151pub struct CallHierarchyCallsParams {
152    /// The call hierarchy item to get calls for (from prepare response).
153    pub item: serde_json::Value,
154}