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}