MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / handle_resources_read

Method handle_resources_read

src/mcp/server.rs:2126–2152  ·  view source on GitHub ↗

Handles the `resources/read` method, returning resource contents.

(&self, id: Value, params: Option<&Value>)

Source from the content-addressed store, hash-verified

2124
2125 /// Handles the `resources/read` method, returning resource contents.
2126 async fn handle_resources_read(&self, id: Value, params: Option<&Value>) -> JsonRpcResponse {
2127 let uri = params.and_then(|p| p.get("uri")).and_then(|v| v.as_str());
2128
2129 let Some(uri) = uri else {
2130 return JsonRpcResponse::error(
2131 id,
2132 ErrorCode::InvalidParams,
2133 "missing 'uri' in resources/read params".to_string(),
2134 );
2135 };
2136 if let Ok(mut counts) = self.resource_read_counts.lock() {
2137 *counts.entry(uri.to_string()).or_insert(0) += 1;
2138 }
2139
2140 match uri {
2141 "tracedecay://status" => self.read_resource_status(id).await,
2142 "tracedecay://files" => self.read_resource_files(id).await,
2143 "tracedecay://overview" => self.read_resource_overview(id).await,
2144 "tracedecay://branches" => self.read_resource_branches(id).await,
2145 "tracedecay://schema" => Self::read_resource_schema(id),
2146 _ => JsonRpcResponse::error(
2147 id,
2148 ErrorCode::InvalidParams,
2149 format!("unknown resource URI: {uri}"),
2150 ),
2151 }
2152 }
2153
2154 /// Returns the `SQLite` schema documentation as a markdown resource.
2155 /// Sourced from `src/db/migrations.rs::create_schema` — keep in sync.

Calls 7

errorFunction · 0.85
entryMethod · 0.80
read_resource_statusMethod · 0.80
read_resource_filesMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected