diff --git a/Cargo.lock b/Cargo.lock index 7d01dcc..efe89f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -436,38 +436,6 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" -[[package]] -name = "rust-cargo-docs-rag-mcp" -version = "0.3.0" -dependencies = [ - "anyhow", - "axum", - "clap", - "flate2", - "futures", - "html2md", - "hyper 0.14.32", - "mcp-core", - "mcp-macros", - "mcp-server", - "mockito", - "rand 0.8.5", - "regex", - "reqwest", - "serde", - "serde_json", - "syn", - "tar", - "tokenizers", - "tokio", - "tokio-util", - "tower 0.4.13", - "tower-service", - "tracing", - "tracing-appender", - "tracing-subscriber", -] - [[package]] name = "crc32fast" version = "1.4.2" @@ -2125,6 +2093,38 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rust-cargo-docs-rag-mcp" +version = "0.3.0" +dependencies = [ + "anyhow", + "axum", + "clap", + "flate2", + "futures", + "html2md", + "hyper 0.14.32", + "mcp-core", + "mcp-macros", + "mcp-server", + "mockito", + "rand 0.8.5", + "regex", + "reqwest", + "serde", + "serde_json", + "syn", + "tar", + "tokenizers", + "tokio", + "tokio-util", + "tower 0.4.13", + "tower-service", + "tracing", + "tracing-appender", + "tracing-subscriber", +] + [[package]] name = "rustc-demangle" version = "0.1.24" diff --git a/README.md b/README.md index 1a996a6..90d1194 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ ## Installation +### Using Cargo (Standard) + ```bash git clone https://github.com/promptexecution/rust-cargo-docs-rag-mcp.git cd rust-cargo-docs-rag-mcp @@ -17,6 +19,23 @@ cargo build --release cargo install --path . ``` +### Using pkgx + +[pkgx](https://pkgx.dev) is a universal package manager that can build and run this project without requiring a system-wide Rust installation: + +```bash +# Install using pkgx (automatically handles Rust dependencies) +pkgx install + +# Or build directly with pkgx +pkgx +rust +cargo cargo build --release + +# Run without installing +pkgx +rust +cargo cargo run --bin cratedocs -- stdio +``` + +The project includes a `package.yml` file for pkgx integration, making it easy to build and test across different environments. + ## Running the Server There are multiple ways to run the documentation server: diff --git a/justfile b/justfile index b680048..d3a80a7 100644 --- a/justfile +++ b/justfile @@ -1,6 +1,18 @@ install: cargo install --git https://github.com/promptexecution/rust-cargo-docs-rag-mcp --locked +# Build with pkgx (ensures correct Rust version and dependencies) +pkgx-build: + pkgx +rust +cargo cargo build --release + +# Run with pkgx +pkgx-run: + pkgx +rust +cargo cargo run --bin cratedocs http --address 0.0.0.0:3000 --debug + +# Test with pkgx +pkgx-test: + pkgx +rust +cargo cargo test + run: cargo run --bin cratedocs http --address 0.0.0.0:3000 --debug diff --git a/package.yml b/package.yml new file mode 100644 index 0000000..eaae5b0 --- /dev/null +++ b/package.yml @@ -0,0 +1,21 @@ +distributable: + url: https://github.com/PromptExecution/rust-cargo-docs-rag-mcp/archive/refs/tags/v{{version}}.tar.gz + strip-components: 1 + +provides: + - bin/cratedocs + +versions: + github: PromptExecution/rust-cargo-docs-rag-mcp/tags + +build: + dependencies: + rust-lang.org: '>=1.70' + rust-lang.org/cargo: '*' + script: | + cargo install --path . --root {{prefix}} + +test: + script: | + cratedocs version + cratedocs test --tool help diff --git a/src/bin/cratedocs.rs b/src/bin/cratedocs.rs index 6223d7f..4f841a3 100644 --- a/src/bin/cratedocs.rs +++ b/src/bin/cratedocs.rs @@ -1,6 +1,6 @@ use anyhow::Result; use clap::{Parser, Subcommand}; -use cratedocs_mcp::tools::DocRouter; +use rust_cargo_docs_rag_mcp::tools::DocRouter; use mcp_core::Content; use mcp_server::router::RouterService; use mcp_server::{ByteTransport, Router, Server}; @@ -9,7 +9,7 @@ use std::net::SocketAddr; use tokio::io::{stdin, stdout}; use tracing_appender::rolling::{RollingFileAppender, Rotation}; use tracing_subscriber::{self, EnvFilter, layer::SubscriberExt, util::SubscriberInitExt}; -use cratedocs_mcp::tools::tldr; +use rust_cargo_docs_rag_mcp::tools::tldr; #[derive(Parser)] #[command(author, version = "0.2.0", about, long_about = None)] @@ -203,7 +203,7 @@ async fn run_http_server(address: String, debug: bool) -> Result<()> { tracing::info!("Access the Rust Documentation Server at http://{}/sse", addr); // Create app and run server - let app = cratedocs_mcp::transport::http_sse_server::App::new(); + let app = rust_cargo_docs_rag_mcp::transport::http_sse_server::App::new(); axum::serve(listener, app.router()).await?; Ok(()) @@ -367,11 +367,11 @@ async fn run_test_tool(config: TestToolConfig) -> Result<()> { // If max_tokens is set, truncate output to fit within the limit if let Some(max_tokens) = max_tokens { - match cratedocs_mcp::tools::count_tokens(&content_str) { + match rust_cargo_docs_rag_mcp::tools::count_tokens(&content_str) { Ok(token_count) if token_count > max_tokens => { // Truncate by character, then to previous word boundary, and append Mandarin to indicate truncation. let mut truncated = content_str.clone(); - while cratedocs_mcp::tools::count_tokens(&truncated).map_or(0, |c| c) > max_tokens && !truncated.is_empty() { + while rust_cargo_docs_rag_mcp::tools::count_tokens(&truncated).map_or(0, |c| c) > max_tokens && !truncated.is_empty() { truncated.pop(); } if let Some(last_space) = truncated.rfind(' ') { @@ -486,7 +486,7 @@ async fn run_test_tool(config: TestToolConfig) -> Result<()> { } #[cfg(test)] mod tldr_tests { - use cratedocs_mcp::tools::tldr::apply_tldr; + use rust_cargo_docs_rag_mcp::tools::tldr::apply_tldr; #[test] fn test_apply_tldr_removes_license_and_versions() { diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index fdea00b..2f27c0a 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1,4 +1,4 @@ -use cratedocs_mcp::{tools::DocRouter, transport::jsonrpc_frame_codec::JsonRpcFrameCodec}; +use rust_cargo_docs_rag_mcp::{tools::DocRouter, transport::jsonrpc_frame_codec::JsonRpcFrameCodec}; use mcp_server::Router; use serde_json::{json, Value}; use tokio_util::codec::Decoder;