Skip to content
Open
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
12 changes: 12 additions & 0 deletions .cargo/config.toml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[env]
# Uncomment and set API keys for integration tests
# These are read by tests/provider_integration.rs
# Tests gracefully skip when keys are not set

#TAVILY_API_KEY = "tvly-xxx"
#WEBSEARCHAPI_KEY = "xxx"
#EXA_API_KEY = "xxx"
#GOOGLE_API_KEY = "xxx"
#GOOGLE_CX = "xxx"
#SERPAPI_API_KEY = "xxx"
#BRAVE_API_KEY = "xxx"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
.env.local
.env.production

# Cargo config with API keys (use .cargo/config.toml.example as template)
.cargo/config.toml

# Rust compilation artifacts
/target/
Cargo.lock
Expand Down
16 changes: 16 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ readme = "README.md"
[package.metadata]
original_typescript_version = "https://github.com/PlustOrg/search-sdk"

[features]
default = []
mcp = ["rmcp", "schemars", "tokio-util", "axum"]

[lib]
name = "websearch"
path = "src/lib.rs"
Expand All @@ -21,6 +25,11 @@ path = "src/lib.rs"
name = "websearch"
path = "src/bin/main.rs"

[[bin]]
name = "websearch-mcp"
path = "src/bin/websearch_mcp.rs"
required-features = ["mcp"]

[dependencies]
# HTTP client
reqwest = { version = "0.11", features = ["json", "rustls-tls"], default-features = false }
Expand Down Expand Up @@ -50,6 +59,12 @@ futures = "0.3"
clap = { version = "4.4", features = ["derive", "env"] }
# Enhanced terminal output
colored = "2.0"
# MCP server (optional)
rmcp = { version = "0.12", features = ["server", "transport-io", "transport-streamable-http-server", "macros"], optional = true }
schemars = { version = "1.1", optional = true }
tokio-util = { version = "0.7", optional = true }
# HTTP server for MCP HTTP transport (optional)
axum = { version = "0.8", optional = true }

[dev-dependencies]
tokio-test = "0.4"
Expand All @@ -58,3 +73,4 @@ env_logger = "0.10"
tempfile = "3.8"
wiremock = "0.5"
serial_test = "3.0"
rstest = "0.23"
49 changes: 49 additions & 0 deletions Dockerfile.mcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# WebSearch MCP Server Dockerfile
#
# Build:
# docker build -f Dockerfile.mcp -t websearch-mcp .
#
# Run:
# docker run -p 3000:3000 -e WEBSEARCHAPI_KEY=your-key websearch-mcp

FROM rust:1.88-slim-bookworm AS builder

WORKDIR /app

# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*

# Copy manifests
COPY Cargo.toml Cargo.lock* ./

# Copy source
COPY src ./src
COPY tests ./tests

# Build release binary with MCP feature
RUN cargo build --release --features mcp --bin websearch-mcp

# Runtime image
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/target/release/websearch-mcp /usr/local/bin/websearch-mcp

EXPOSE 3000

HEALTHCHECK --interval=10s --timeout=5s --retries=5 \
CMD curl -sf http://localhost:3000/health || exit 1

# Default to HTTP transport for container deployments
ENV WEBSEARCH_TRANSPORT=http
ENV WEBSEARCH_BIND_ADDR=0.0.0.0:3000
ENV WEBSEARCH_DEFAULT_PROVIDER=duckduckgo

ENTRYPOINT ["/usr/local/bin/websearch-mcp"]
Loading