Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Mar 5, 2025
1 parent 917e50d commit fc1f1cb
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 41 deletions.
4 changes: 2 additions & 2 deletions crates/torii/mcp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod types;
pub mod resources;
pub mod tools;
pub mod resources;
pub mod types;
2 changes: 1 addition & 1 deletion crates/torii/mcp/src/resources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ pub struct Resource {

pub fn get_resources() -> Vec<Resource> {
vec![] // Add resources as needed
}
}

Check warning on line 8 in crates/torii/mcp/src/resources/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/mcp/src/resources/mod.rs#L6-L8

Added lines #L6 - L8 were not covered by tests
7 changes: 2 additions & 5 deletions crates/torii/mcp/src/tools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,5 @@ pub struct Tool {
}

pub fn get_tools() -> Vec<Tool> {
vec![
query::get_tool(),
schema::get_tool(),
]
}
vec![query::get_tool(), schema::get_tool()]
}

Check warning on line 15 in crates/torii/mcp/src/tools/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/mcp/src/tools/mod.rs#L13-L15

Added lines #L13 - L15 were not covered by tests
6 changes: 2 additions & 4 deletions crates/torii/mcp/src/tools/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ use std::sync::Arc;

use serde_json::{json, Value};
use sqlx::SqlitePool;

use crate::types::{JsonRpcRequest, JsonRpcResponse, JsonRpcError};
use torii_sqlite::utils::map_row_to_json;
use crate::types::JSONRPC_VERSION;

use super::Tool;
use crate::types::{JsonRpcError, JsonRpcRequest, JsonRpcResponse, JSONRPC_VERSION};

pub fn get_tool() -> Tool {
Tool {
Expand Down Expand Up @@ -73,4 +71,4 @@ pub async fn handle(pool: Arc<SqlitePool>, request: JsonRpcRequest) -> JsonRpcRe
}),
}

Check warning on line 72 in crates/torii/mcp/src/tools/query.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/mcp/src/tools/query.rs#L63-L72

Added lines #L63 - L72 were not covered by tests
}
}
}

Check warning on line 74 in crates/torii/mcp/src/tools/query.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/mcp/src/tools/query.rs#L74

Added line #L74 was not covered by tests
8 changes: 3 additions & 5 deletions crates/torii/mcp/src/tools/schema.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use std::sync::Arc;

use serde_json::{json, Value};
use sqlx::SqlitePool;
use sqlx::Row;
use crate::types::{JsonRpcRequest, JsonRpcResponse, JsonRpcError};
use crate::types::JSONRPC_VERSION;
use sqlx::{Row, SqlitePool};

use super::Tool;
use crate::types::{JsonRpcError, JsonRpcRequest, JsonRpcResponse, JSONRPC_VERSION};

pub fn get_tool() -> Tool {
Tool {
Expand Down Expand Up @@ -113,4 +111,4 @@ pub async fn handle(pool: Arc<SqlitePool>, request: JsonRpcRequest) -> JsonRpcRe
}),
},

Check warning on line 112 in crates/torii/mcp/src/tools/schema.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/mcp/src/tools/schema.rs#L103-L112

Added lines #L103 - L112 were not covered by tests
}
}
}

Check warning on line 114 in crates/torii/mcp/src/tools/schema.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/mcp/src/tools/schema.rs#L114

Added line #L114 was not covered by tests
2 changes: 1 addition & 1 deletion crates/torii/mcp/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ impl JsonRpcResponse {
pub fn parse_error(id: Value, details: &str) -> Self {
Self::error(id, -32700, "Parse error", Some(json!({ "details": details })))
}

Check warning on line 108 in crates/torii/mcp/src/types/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/mcp/src/types/mod.rs#L106-L108

Added lines #L106 - L108 were not covered by tests
}
}
38 changes: 17 additions & 21 deletions crates/torii/server/src/handlers/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use serde_json::{json, Value};
use sqlx::SqlitePool;
use tokio::sync::{broadcast, RwLock};
use tokio_tungstenite::tungstenite::Message;
use torii_mcp::{tools::{self, Tool}, resources::{self, Resource}};
use tracing::warn;
use uuid::Uuid;

use torii_mcp::resources::{self, Resource};
use torii_mcp::tools::{self, Tool};
use torii_mcp::types::{
JsonRpcMessage, JsonRpcRequest, JsonRpcResponse, SseSession,
JSONRPC_VERSION, MCP_VERSION, SSE_CHANNEL_CAPACITY,
JsonRpcMessage, JsonRpcRequest, JsonRpcResponse, SseSession, JSONRPC_VERSION, MCP_VERSION,
SSE_CHANNEL_CAPACITY,
};
use tracing::warn;
use uuid::Uuid;

use super::Handler;

Expand Down Expand Up @@ -213,20 +213,16 @@ impl McpHandler {

async fn handle_message_request(&self, req: Request<Body>) -> Response<Body> {
// Extract session ID from query parameters
let session_id = req
.uri()
.query()
.and_then(|q| {
q.split('&')
.find_map(|p| {
let parts: Vec<&str> = p.split('=').collect();
if parts.len() == 2 && parts[0] == "sessionId" {
Some(parts[1].to_string())
} else {
None
}
})
});
let session_id = req.uri().query().and_then(|q| {
q.split('&').find_map(|p| {
let parts: Vec<&str> = p.split('=').collect();
if parts.len() == 2 && parts[0] == "sessionId" {
Some(parts[1].to_string())

Check warning on line 220 in crates/torii/server/src/handlers/mcp.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/server/src/handlers/mcp.rs#L214-L220

Added lines #L214 - L220 were not covered by tests
} else {
None

Check warning on line 222 in crates/torii/server/src/handlers/mcp.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/server/src/handlers/mcp.rs#L222

Added line #L222 was not covered by tests
}
})
});

if session_id.is_none() {
return Response::builder()
Expand Down Expand Up @@ -343,4 +339,4 @@ impl Handler for McpHandler {
.unwrap(),

Check warning on line 339 in crates/torii/server/src/handlers/mcp.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/server/src/handlers/mcp.rs#L335-L339

Added lines #L335 - L339 were not covered by tests
}
}
}
}
4 changes: 2 additions & 2 deletions crates/torii/sqlite/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ use std::str::FromStr;
use std::time::Duration;

use anyhow::Result;
use base64::Engine;
use base64::engine::general_purpose::STANDARD;
use base64::Engine;
use chrono::{DateTime, Utc};
use futures_util::TryStreamExt;
use ipfs_api_backend_hyper::{IpfsApi, IpfsClient, TryFromUri};
use once_cell::sync::Lazy;
use reqwest::Client;
use sqlx::{Column, Row, TypeInfo};
use starknet::core::types::U256;
use starknet_crypto::Felt;
use tokio_util::bytes::Bytes;
use tracing::debug;
use sqlx::{Column, Row, TypeInfo};

use crate::constants::{
IPFS_CLIENT_PASSWORD, IPFS_CLIENT_URL, IPFS_CLIENT_USERNAME, REQ_MAX_RETRIES,
Expand Down

0 comments on commit fc1f1cb

Please sign in to comment.