Skip to content

ci: add documentation generation job #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2025
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
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@ jobs:
- name: Run tests
run: cargo test --all-features

doc:
name: Generate Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: Generate documentation
run: |
cargo doc --no-deps -p rmcp -p rmcp-macros
env:
RUSTDOCFLAGS: -Dwarnings

release:
name: Release crates
runs-on: ubuntu-latest
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ Start a client in one line:
use rmcp::{ServiceExt, transport::TokioChildProcess};
use tokio::process::Command;

let client = ().serve(
TokioChildProcess::new(Command::new("npx").arg("-y").arg("@modelcontextprotocol/server-everything"))?
).await?;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ().serve(
TokioChildProcess::new(Command::new("npx").arg("-y").arg("@modelcontextprotocol/server-everything"))?
).await?;
Ok(())
}
```

#### 1. Build a transport
Expand Down
183 changes: 0 additions & 183 deletions crates/rmcp/README.md

This file was deleted.

1 change: 0 additions & 1 deletion crates/rmcp/src/lib.rs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure it's OK when publishing package? I used to do so but it turns out cargo can not find the readme when package rmcp.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be a separate crate file that has been opened in crate. doc, so there is no way to access the readme in the upper level directory.
I would like to add a separate readme to each crate in the future and use the top-level readme as an index to view the documentation for each crate. What do you think of this ?(to be modified before publishing)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we copy the readme in root dir to crate dir when packaging crate? Or can we create a symlink from crate level readme to root dir?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think copying a past plan is not feasible. We should try our best to avoid duplicate file copying and usage, The symbolic link of crate should not be feasible. I think providing links to the documentation of each crate through the root readme is the best way, as most projects do this.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]
mod error;
pub use error::Error;

Expand Down
15 changes: 7 additions & 8 deletions examples/servers/src/common/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,13 @@ impl ServerHandler for Counter {
match name.as_str() {
"example_prompt" => {
let message = arguments
.and_then(
|json|
json.get("message")
?.as_str()
.map(|s| s.to_string()))
.ok_or_else(|| McpError::invalid_params("No message provided to example_prompt", None))?;

let prompt = format!("This is an example prompt with your message here: '{message}'");
.and_then(|json| json.get("message")?.as_str().map(|s| s.to_string()))
.ok_or_else(|| {
McpError::invalid_params("No message provided to example_prompt", None)
})?;

let prompt =
format!("This is an example prompt with your message here: '{message}'");
Ok(GetPromptResult {
description: None,
messages: vec![PromptMessage {
Expand Down
Loading