Skip to content

Commit 5275a24

Browse files
Merge pull request #5 from PromptExecution/copilot/fix-pkgx-build-issue
Fix build failure and add pkgx package configuration
2 parents 5651103 + abc8eb8 commit 5275a24

File tree

6 files changed

+91
-39
lines changed

6 files changed

+91
-39
lines changed

Cargo.lock

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,32 @@
1010

1111
## Installation
1212

13+
### Using Cargo (Standard)
14+
1315
```bash
1416
git clone https://github.com/promptexecution/rust-cargo-docs-rag-mcp.git
1517
cd rust-cargo-docs-rag-mcp
1618
cargo build --release
1719
cargo install --path .
1820
```
1921

22+
### Using pkgx
23+
24+
[pkgx](https://pkgx.dev) is a universal package manager that can build and run this project without requiring a system-wide Rust installation:
25+
26+
```bash
27+
# Install using pkgx (automatically handles Rust dependencies)
28+
pkgx install
29+
30+
# Or build directly with pkgx
31+
pkgx +rust +cargo cargo build --release
32+
33+
# Run without installing
34+
pkgx +rust +cargo cargo run --bin cratedocs -- stdio
35+
```
36+
37+
The project includes a `package.yml` file for pkgx integration, making it easy to build and test across different environments.
38+
2039
## Running the Server
2140

2241
There are multiple ways to run the documentation server:

justfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
install:
22
cargo install --git https://github.com/promptexecution/rust-cargo-docs-rag-mcp --locked
33

4+
# Build with pkgx (ensures correct Rust version and dependencies)
5+
pkgx-build:
6+
pkgx +rust +cargo cargo build --release
7+
8+
# Run with pkgx
9+
pkgx-run:
10+
pkgx +rust +cargo cargo run --bin cratedocs http --address 0.0.0.0:3000 --debug
11+
12+
# Test with pkgx
13+
pkgx-test:
14+
pkgx +rust +cargo cargo test
15+
416
run:
517
cargo run --bin cratedocs http --address 0.0.0.0:3000 --debug
618

package.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
distributable:
2+
url: https://github.com/PromptExecution/rust-cargo-docs-rag-mcp/archive/refs/tags/v{{version}}.tar.gz
3+
strip-components: 1
4+
5+
provides:
6+
- bin/cratedocs
7+
8+
versions:
9+
github: PromptExecution/rust-cargo-docs-rag-mcp/tags
10+
11+
build:
12+
dependencies:
13+
rust-lang.org: '>=1.70'
14+
rust-lang.org/cargo: '*'
15+
script: |
16+
cargo install --path . --root {{prefix}}
17+
18+
test:
19+
script: |
20+
cratedocs version
21+
cratedocs test --tool help

src/bin/cratedocs.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::Result;
22
use clap::{Parser, Subcommand};
3-
use cratedocs_mcp::tools::DocRouter;
3+
use rust_cargo_docs_rag_mcp::tools::DocRouter;
44
use mcp_core::Content;
55
use mcp_server::router::RouterService;
66
use mcp_server::{ByteTransport, Router, Server};
@@ -9,7 +9,7 @@ use std::net::SocketAddr;
99
use tokio::io::{stdin, stdout};
1010
use tracing_appender::rolling::{RollingFileAppender, Rotation};
1111
use tracing_subscriber::{self, EnvFilter, layer::SubscriberExt, util::SubscriberInitExt};
12-
use cratedocs_mcp::tools::tldr;
12+
use rust_cargo_docs_rag_mcp::tools::tldr;
1313

1414
#[derive(Parser)]
1515
#[command(author, version = "0.2.0", about, long_about = None)]
@@ -203,7 +203,7 @@ async fn run_http_server(address: String, debug: bool) -> Result<()> {
203203
tracing::info!("Access the Rust Documentation Server at http://{}/sse", addr);
204204

205205
// Create app and run server
206-
let app = cratedocs_mcp::transport::http_sse_server::App::new();
206+
let app = rust_cargo_docs_rag_mcp::transport::http_sse_server::App::new();
207207
axum::serve(listener, app.router()).await?;
208208

209209
Ok(())
@@ -367,11 +367,11 @@ async fn run_test_tool(config: TestToolConfig) -> Result<()> {
367367

368368
// If max_tokens is set, truncate output to fit within the limit
369369
if let Some(max_tokens) = max_tokens {
370-
match cratedocs_mcp::tools::count_tokens(&content_str) {
370+
match rust_cargo_docs_rag_mcp::tools::count_tokens(&content_str) {
371371
Ok(token_count) if token_count > max_tokens => {
372372
// Truncate by character, then to previous word boundary, and append Mandarin to indicate truncation.
373373
let mut truncated = content_str.clone();
374-
while cratedocs_mcp::tools::count_tokens(&truncated).map_or(0, |c| c) > max_tokens && !truncated.is_empty() {
374+
while rust_cargo_docs_rag_mcp::tools::count_tokens(&truncated).map_or(0, |c| c) > max_tokens && !truncated.is_empty() {
375375
truncated.pop();
376376
}
377377
if let Some(last_space) = truncated.rfind(' ') {
@@ -486,7 +486,7 @@ async fn run_test_tool(config: TestToolConfig) -> Result<()> {
486486
}
487487
#[cfg(test)]
488488
mod tldr_tests {
489-
use cratedocs_mcp::tools::tldr::apply_tldr;
489+
use rust_cargo_docs_rag_mcp::tools::tldr::apply_tldr;
490490

491491
#[test]
492492
fn test_apply_tldr_removes_license_and_versions() {

tests/integration_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use cratedocs_mcp::{tools::DocRouter, transport::jsonrpc_frame_codec::JsonRpcFrameCodec};
1+
use rust_cargo_docs_rag_mcp::{tools::DocRouter, transport::jsonrpc_frame_codec::JsonRpcFrameCodec};
22
use mcp_server::Router;
33
use serde_json::{json, Value};
44
use tokio_util::codec::Decoder;

0 commit comments

Comments
 (0)