Skip to main content

database_mcp_backend/
types.rs

1//! Request types for MCP tool parameters.
2//!
3//! Each struct maps to the JSON input schema of one MCP tool.
4
5use rmcp::schemars;
6use rmcp::schemars::JsonSchema;
7use serde::Deserialize;
8
9/// Request to list tables in a database.
10#[derive(Debug, Deserialize, JsonSchema)]
11pub struct ListTablesRequest {
12    #[schemars(
13        description = "The database name to list tables from. Required. Use list_databases first to see available databases."
14    )]
15    pub database_name: String,
16}
17
18/// Request to get a table's schema.
19#[derive(Debug, Deserialize, JsonSchema)]
20pub struct GetTableSchemaRequest {
21    #[schemars(
22        description = "The database name containing the table. Required. Use list_databases first to see available databases."
23    )]
24    pub database_name: String,
25    #[schemars(
26        description = "The table name to inspect. Use list_tables first to see available tables in the database."
27    )]
28    pub table_name: String,
29}
30
31/// Request for `read_query` and `write_query` tools.
32#[derive(Debug, Deserialize, JsonSchema)]
33pub struct QueryRequest {
34    #[schemars(description = "The SQL query to execute.")]
35    pub sql_query: String,
36    #[schemars(
37        description = "The database to run the query against. Required. Use list_databases first to see available databases."
38    )]
39    pub database_name: String,
40}
41
42/// Request to create a database.
43#[derive(Debug, Deserialize, JsonSchema)]
44pub struct CreateDatabaseRequest {
45    #[schemars(
46        description = "Name of the database to create. Must contain only alphanumeric characters and underscores."
47    )]
48    pub database_name: String,
49}