Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,32 @@

## Installation

### Using Cargo (Standard)

```bash
git clone https://github.com/promptexecution/rust-cargo-docs-rag-mcp.git
cd rust-cargo-docs-rag-mcp
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:
Expand Down
12 changes: 12 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
21 changes: 21 additions & 0 deletions package.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions src/bin/cratedocs.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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)]
Expand Down Expand Up @@ -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(())
Expand Down Expand Up @@ -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(' ') {
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading