Skip to main content

HyperMcpServer

Struct HyperMcpServer 

Source
pub struct HyperMcpServer { /* private fields */ }
Expand description

The MCP server that registers all Hyper tools and routes invocations.

The Engine is lazily initialized behind a Mutex<Option<Engine>> so that the expensive HyperProcess startup only happens on the first actual tool call, not during MCP handshake. This keeps initialize fast and avoids starting hyperd if the client never calls a tool.

Implementations§

Source§

impl HyperMcpServer

Source

pub fn new(persistent_path: Option<String>, read_only: bool) -> Self

Create a server instance. Pass Some(path) for persistent workspace, None for ephemeral (temp directory, auto-cleaned).

The saved-queries store is chosen to match the workspace mode: persistent workspaces get a crate::saved_queries::WorkspaceStore (backed by a meta-table in the .hyper file so queries survive restarts), ephemeral workspaces get an in-memory crate::saved_queries::SessionStore.

When read_only is true, the execute, load_data, load_file, save_query, delete_query, and set_table_metadata tools return a ReadOnlyViolation error, and exporting to the hyper format (which is a raw file copy, harmless) remains allowed.

When bare is true, the server does not create or maintain the _table_catalog table, and saved queries fall back to the in-memory crate::saved_queries::SessionStore regardless of workspace_path persistent_path is the resolved path to the persistent database (Some) or None for --ephemeral-only mode.

Source

pub fn with_no_daemon( persistent_path: Option<String>, read_only: bool, no_daemon: bool, ) -> Self

Create a server instance with explicit daemon control.

Source

pub fn subscriptions_handle(&self) -> Arc<SubscriptionRegistry>

Return a clone of the subscription registry so background tasks (notably the directory watcher) can fire resource updates after their own ingest completes.

Source

pub fn engine_handle(&self) -> Arc<Mutex<Option<Engine>>>

Return a clone of the engine Arc so background tasks (watchers) can share access to the same lazy-initialized engine instance.

Source

pub fn watchers_handle(&self) -> Arc<WatcherRegistry>

Return a clone of the watcher registry handle for tool handlers.

Source

pub fn attachments_handle(&self) -> Arc<AttachRegistry>

Return a clone of the attachments registry handle for tool handlers and the with_engine replay path.

Source

pub fn is_read_only(&self) -> bool

Whether the server is running in read-only mode.

Source

pub fn warm_up_engine(&self)

Eagerly initialize the engine at server startup, before any tool call arrives. This makes read-only observer tools like status able to report full stats on the very first call without having to trigger initialization themselves — status stays a pure, non-blocking observer (honoring issue #118).

Errors are logged and swallowed rather than propagated: if hyperd is unreachable at startup the server still comes up, and the first data-plane tool call will retry initialization via with_engine.

Source§

impl HyperMcpServer

Source

pub fn query_data_tool_attr() -> Tool

Generated tool metadata function for query_data

Source

pub fn query_file_tool_attr() -> Tool

Generated tool metadata function for query_file

Source

pub fn load_data_tool_attr() -> Tool

Generated tool metadata function for load_data

Source

pub fn load_file_tool_attr() -> Tool

Generated tool metadata function for load_file

Source

pub fn load_files_tool_attr() -> Tool

Generated tool metadata function for load_files

Source

pub fn load_iceberg_tool_attr() -> Tool

Generated tool metadata function for load_iceberg

Source

pub fn query_tool_attr() -> Tool

Generated tool metadata function for query

Source

pub fn execute_tool_attr() -> Tool

Generated tool metadata function for execute

Source

pub fn sample_tool_attr() -> Tool

Generated tool metadata function for sample

Source

pub fn chart_tool_attr() -> Tool

Generated tool metadata function for chart

Source

pub fn watch_directory_tool_attr() -> Tool

Generated tool metadata function for watch_directory

Source

pub fn unwatch_directory_tool_attr() -> Tool

Generated tool metadata function for unwatch_directory

Source

pub fn describe_tool_attr() -> Tool

Generated tool metadata function for describe

Source

pub fn inspect_file_tool_attr() -> Tool

Generated tool metadata function for inspect_file

Source

pub fn export_tool_attr() -> Tool

Generated tool metadata function for export

Source

pub fn save_query_tool_attr() -> Tool

Generated tool metadata function for save_query

Source

pub fn delete_query_tool_attr() -> Tool

Generated tool metadata function for delete_query

Source

pub fn set_table_metadata_tool_attr() -> Tool

Generated tool metadata function for set_table_metadata

Source

pub fn kv_get_tool_attr() -> Tool

Generated tool metadata function for kv_get

Source

pub fn kv_set_tool_attr() -> Tool

Generated tool metadata function for kv_set

Source

pub fn kv_delete_tool_attr() -> Tool

Generated tool metadata function for kv_delete

Source

pub fn kv_list_tool_attr() -> Tool

Generated tool metadata function for kv_list

Source

pub fn kv_list_stores_tool_attr() -> Tool

Generated tool metadata function for kv_list_stores

Source

pub fn kv_size_tool_attr() -> Tool

Generated tool metadata function for kv_size

Source

pub fn kv_pop_tool_attr() -> Tool

Generated tool metadata function for kv_pop

Source

pub fn kv_clear_tool_attr() -> Tool

Generated tool metadata function for kv_clear

Source

pub fn status_tool_attr() -> Tool

Generated tool metadata function for status

Source

pub fn get_readme_tool_attr() -> Tool

Generated tool metadata function for get_readme

Source

pub fn attach_database_tool_attr() -> Tool

Generated tool metadata function for attach_database

Source

pub fn detach_database_tool_attr() -> Tool

Generated tool metadata function for detach_database

Source

pub fn list_attached_databases_tool_attr() -> Tool

Generated tool metadata function for list_attached_databases

Source

pub fn copy_query_tool_attr() -> Tool

Generated tool metadata function for copy_query

Source§

impl HyperMcpServer

Source

pub fn analyze_table_prompt_attr() -> Prompt

Source

pub fn analyze_table( &self, Parameters: Parameters<AnalyzeTableArgs>, ) -> Pin<Box<dyn Future<Output = Vec<PromptMessage>> + Send + '_>>

Deep analysis of a single table: schema, sample, column statistics, data quality flags.

Source

pub fn compare_tables_prompt_attr() -> Prompt

Source

pub fn compare_tables( &self, Parameters: Parameters<CompareTablesArgs>, ) -> Pin<Box<dyn Future<Output = Vec<PromptMessage>> + Send + '_>>

Compare two tables side-by-side: schema alignment, common keys, JOIN suggestions.

Source

pub fn data_quality_prompt_attr() -> Prompt

Source

pub fn data_quality( &self, Parameters: Parameters<DataQualityArgs>, ) -> Pin<Box<dyn Future<Output = Vec<PromptMessage>> + Send + '_>>

Systematic data quality assessment: nulls, duplicates, cardinality, outliers.

Source

pub fn suggest_queries_prompt_attr() -> Prompt

Source

pub fn suggest_queries( &self, Parameters: Parameters<SuggestQueriesArgs>, ) -> Pin<Box<dyn Future<Output = Vec<PromptMessage>> + Send + '_>>

Propose useful analytical queries for a table, optionally guided by a goal.

Source§

impl HyperMcpServer

Source

pub fn resource_body_for_uri( &self, uri: &str, ) -> Result<Option<ResourceBody>, McpError>

Produce the body for a resource URI without constructing an MCP RequestContext. Factored out of Self::read_resource so tests can exercise URI dispatch without standing up the full MCP runtime.

Returns Ok(None) if the URI isn’t recognized at all (the async trait method surfaces this as an invalid_params error to clients).

The returned ResourceBody carries its own MIME type so non-JSON resources (hyper://readme, hyper://tables/{name}/csv-sample, etc.) can be served verbatim as markdown / CSV.

§Errors

Propagates any McpError from the underlying engine call (status probe, table description, CSV sample, saved-query listing, etc.) and bubbles up ErrorCode::TableNotFound for hyper://tables/{name}/... URIs whose table is absent from the workspace.

Source

pub fn list_resource_uris(&self) -> Vec<String>

Produce the list of MCP resources without constructing an MCP RequestContext. Factored out of Self::list_resources for tests.

Returns one URI for the workspace, one for the full tables list, one for the workspace readme, one for the KV store schema, three per existing table (schema, sample, csv-sample), and two per saved query (definition, result).

Trait Implementations§

Source§

impl Debug for HyperMcpServer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ServerHandler for HyperMcpServer

Source§

async fn subscribe( &self, request: SubscribeRequestParams, context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>

Handle a resources/subscribe request by recording the calling peer in the registry under the requested URI.

MCP does not mandate that the server validate the URI exists beforehand — subscriptions to URIs that don’t resolve today (e.g. a saved-query result before save_query is called) are allowed and will start delivering notifications as soon as the URI becomes reachable.

Source§

async fn unsubscribe( &self, request: UnsubscribeRequestParams, context: RequestContext<RoleServer>, ) -> Result<(), ErrorData>

Handle a resources/unsubscribe request. Clears every subscription recorded against the URI in this process (see the module-level docs on crate::subscriptions for why we don’t attempt to match peers individually).

Source§

async fn list_resources( &self, _request: Option<PaginatedRequestParams>, _context: RequestContext<RoleServer>, ) -> Result<ListResourcesResult, ErrorData>

List MCP resources: the workspace, the tables list, a markdown readme, the KV store schema, and three entries per existing table (schema, JSON sample, CSV sample). Calling this lazily starts the engine, so it doubles as a “wake up” signal for MCP clients that pre-fetch resources at connection time.

Source§

async fn list_resource_templates( &self, _request: Option<PaginatedRequestParams>, _context: RequestContext<RoleServer>, ) -> Result<ListResourceTemplatesResult, ErrorData>

Advertise URI templates so clients can construct resource URIs for tables they know about without round-tripping list_resources.

Source§

async fn read_resource( &self, request: ReadResourceRequestParams, _context: RequestContext<RoleServer>, ) -> Result<ReadResourceResult, ErrorData>

Read a resource by URI. Dispatches via HyperMcpServer::resource_body_for_uri which returns both the content and its MIME type (JSON for metadata URIs, markdown for the workspace readme, CSV for per-table samples).

Source§

fn get_info(&self) -> ServerInfo

Source§

async fn initialize( &self, request: InitializeRequestParams, context: RequestContext<RoleServer>, ) -> Result<InitializeResult, ErrorData>

Source§

async fn call_tool( &self, request: CallToolRequestParams, context: RequestContext<RoleServer>, ) -> Result<CallToolResult, ErrorData>

Handle a tools/call request from a client. Read more
Source§

async fn list_tools( &self, _request: Option<PaginatedRequestParams>, _context: RequestContext<RoleServer>, ) -> Result<ListToolsResult, ErrorData>

Source§

fn get_tool(&self, name: &str) -> Option<Tool>

Get a tool definition by name. Read more
Source§

async fn get_prompt( &self, request: GetPromptRequestParams, context: RequestContext<RoleServer>, ) -> Result<GetPromptResult, ErrorData>

Source§

async fn list_prompts( &self, _request: Option<PaginatedRequestParams>, _context: RequestContext<RoleServer>, ) -> Result<ListPromptsResult, ErrorData>

Source§

fn enqueue_task( &self, _request: CallToolRequestParams, _context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CreateTaskResult, ErrorData>> + MaybeSendFuture

Source§

fn ping( &self, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

Source§

fn complete( &self, request: CompleteRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CompleteResult, ErrorData>> + MaybeSendFuture

Source§

fn set_level( &self, request: SetLevelRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

Source§

fn on_custom_request( &self, request: CustomRequest, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CustomResult, ErrorData>> + MaybeSendFuture

Source§

fn on_cancelled( &self, notification: CancelledNotificationParam, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

Source§

fn on_progress( &self, notification: ProgressNotificationParam, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

Source§

fn on_initialized( &self, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

Source§

fn on_roots_list_changed( &self, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

Source§

fn on_custom_notification( &self, notification: CustomNotification, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

Source§

fn list_tasks( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListTasksResult, ErrorData>> + MaybeSendFuture

Source§

fn get_task_info( &self, request: GetTaskInfoParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetTaskResult, ErrorData>> + MaybeSendFuture

Source§

fn get_task_result( &self, request: GetTaskResultParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetTaskPayloadResult, ErrorData>> + MaybeSendFuture

Source§

fn cancel_task( &self, request: CancelTaskParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CancelTaskResult, ErrorData>> + MaybeSendFuture

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<R, S> DynService<R> for S
where R: ServiceRole, S: Service<R>,

Source§

fn handle_request( &self, request: <R as ServiceRole>::PeerReq, context: RequestContext<R>, ) -> Pin<Box<dyn Future<Output = Result<<R as ServiceRole>::Resp, ErrorData>> + Send + '_>>

Source§

fn handle_notification( &self, notification: <R as ServiceRole>::PeerNot, context: NotificationContext<R>, ) -> Pin<Box<dyn Future<Output = Result<(), ErrorData>> + Send + '_>>

Source§

fn get_info(&self) -> <R as ServiceRole>::Info

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<H> Service<RoleServer> for H
where H: ServerHandler,

Source§

impl<S> ServiceExt<RoleServer> for S
where S: Service<RoleServer>,

Source§

fn serve_with_ct<T, E, A>( self, transport: T, ct: CancellationToken, ) -> impl Future<Output = Result<RunningService<RoleServer, S>, ServerInitializeError>> + MaybeSendFuture
where T: IntoTransport<RoleServer, E, A>, E: Error + Send + Sync + 'static, S: Sized,

Source§

fn into_dyn(self) -> Box<dyn DynService<R>>

Convert this service to a dynamic boxed service Read more
Source§

fn serve<T, E, A>( self, transport: T, ) -> impl Future<Output = Result<RunningService<R, Self>, <R as ServiceRole>::InitializeError>> + MaybeSendFuture
where T: IntoTransport<R, E, A>, E: Error + Send + Sync + 'static, Self: Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more