Skip to content

Commit f9b9208

Browse files
RahulHereRahulHere
authored andcommitted
Resolve auth FFI bindings and rename package to gopher-mcp-rust (#2)
FFI fixes: - Fix library name: libgopher_auth -> libgopher-orch (the actual library) - Fix gopher_auth_client_create parameter order to match C API (output param first, not last) - Fix symbol name: gopher_auth_set_option -> gopher_auth_client_set_option - Add DYLD_LIBRARY_PATH/LD_LIBRARY_PATH to library search paths Package rename: - Rename package from gopher-orch to gopher-mcp-rust - Update lib name to gopher_mcp_rust - Update all imports in examples/auth to use new crate name - Use path dependency for local development
1 parent 2fafe30 commit f9b9208

File tree

5 files changed

+63
-27
lines changed

5 files changed

+63
-27
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
[package]
2-
name = "gopher-orch"
3-
version = "0.1.0"
2+
name = "gopher-mcp-rust"
3+
version = "0.1.2-9"
44
edition = "2021"
55
authors = ["GopherSecurity"]
66
description = "Rust SDK for Gopher Orch - AI Agent orchestration framework"
7-
license = "MIT"
7+
license = "Apache-2.0"
88
repository = "https://github.com/GopherSecurity/gopher-mcp-rust"
99
keywords = ["ai", "agent", "mcp", "llm", "orchestration"]
1010
categories = ["api-bindings", "development-tools"]
1111

1212
[lib]
13-
name = "gopher_orch"
13+
name = "gopher_mcp_rust"
1414
path = "src/lib.rs"
1515

1616
[[example]]

examples/auth/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "auth-mcp-server"
33
version = "0.1.0"
44
edition = "2021"
5-
description = "OAuth-protected MCP server example using gopher-orch SDK"
5+
description = "OAuth-protected MCP server example using gopher-mcp-rust SDK"
66
license = "MIT"
77

88
[dependencies]
@@ -21,9 +21,9 @@ serde_json = "1"
2121
# HTTP types
2222
http = "1"
2323

24-
# Gopher Orch SDK with auth FFI
25-
# Use git dependency for standalone example
26-
gopher-orch = { git = "https://github.com/GopherSecurity/gopher-mcp-rust.git", features = ["auth"] }
24+
# Gopher MCP Rust SDK with auth FFI
25+
# Use path dependency for local development
26+
gopher-mcp-rust = { path = "../..", features = ["auth"] }
2727

2828
# Logging
2929
tracing = "0.1"

examples/auth/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use axum::{
1111
use serde::Serialize;
1212
use thiserror::Error;
1313

14-
// Re-export gopher_orch error for convenience
15-
pub use gopher_orch::Error as GopherOrchError;
14+
// Re-export gopher_mcp_rust error for convenience
15+
pub use gopher_mcp_rust::Error as GopherOrchError;
1616

1717
/// Application error type.
1818
#[derive(Error, Debug)]

examples/auth/src/ffi/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
//! FFI bindings module.
22
//!
3-
//! Re-exports gopher-auth types from the gopher-orch library with a thin
3+
//! Re-exports gopher-auth types from the gopher-mcp-rust library with a thin
44
//! wrapper to support testing without the native library.
55
66
use crate::error::AppError;
77

88
// Re-export payload types directly
9-
pub use gopher_orch::TokenPayload;
10-
pub use gopher_orch::ValidationResult;
9+
pub use gopher_mcp_rust::TokenPayload;
10+
pub use gopher_mcp_rust::ValidationResult;
1111

12-
/// Wrapper around gopher-orch's GopherAuthClient.
12+
/// Wrapper around gopher-mcp-rust's GopherAuthClient.
1313
///
1414
/// Provides the same interface but allows creating dummy instances for testing.
1515
pub struct GopherAuthClient {
16-
inner: Option<gopher_orch::GopherAuthClient>,
16+
inner: Option<gopher_mcp_rust::GopherAuthClient>,
1717
}
1818

1919
unsafe impl Send for GopherAuthClient {}
@@ -22,7 +22,7 @@ unsafe impl Sync for GopherAuthClient {}
2222
impl GopherAuthClient {
2323
/// Create a new client.
2424
pub fn new(jwks_uri: &str, issuer: &str) -> Result<Self, AppError> {
25-
let inner = gopher_orch::GopherAuthClient::new(jwks_uri, issuer)?;
25+
let inner = gopher_mcp_rust::GopherAuthClient::new(jwks_uri, issuer)?;
2626
Ok(Self { inner: Some(inner) })
2727
}
2828

src/ffi/auth.rs

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ pub struct TokenPayload {
7373
// FFI function type definitions
7474
type GopherAuthInitFn = unsafe extern "C" fn() -> c_int;
7575
type GopherAuthClientCreateFn = unsafe extern "C" fn(
76+
out: *mut *mut c_void,
7677
jwks_uri: *const c_char,
7778
issuer: *const c_char,
78-
out: *mut *mut c_void,
7979
) -> c_int;
8080
type GopherAuthClientDestroyFn = unsafe extern "C" fn(client: *mut c_void);
8181
type GopherAuthSetOptionFn =
@@ -167,7 +167,7 @@ impl GopherAuthClient {
167167
})?;
168168

169169
let mut handle: *mut c_void = ptr::null_mut();
170-
let result = create(jwks_uri_c.as_ptr(), issuer_c.as_ptr(), &mut handle);
170+
let result = create(&mut handle, jwks_uri_c.as_ptr(), issuer_c.as_ptr());
171171

172172
if result != 0 || handle.is_null() {
173173
return Err(Error::auth(format!(
@@ -184,23 +184,59 @@ impl GopherAuthClient {
184184

185185
/// Load the native library from known locations.
186186
fn load_library() -> Result<Library, Error> {
187-
// Try multiple library names and locations
187+
// Try multiple library names - the auth functions are in libgopher-orch
188188
let lib_names = if cfg!(target_os = "macos") {
189-
vec!["libgopher_auth.dylib", "gopher_auth.dylib"]
189+
vec![
190+
"libgopher-orch.dylib",
191+
"libgopher-orch.0.dylib",
192+
"libgopher_orch.dylib",
193+
]
190194
} else if cfg!(target_os = "windows") {
191-
vec!["gopher_auth.dll", "libgopher_auth.dll"]
195+
vec!["gopher-orch.dll", "libgopher-orch.dll", "gopher_orch.dll"]
192196
} else {
193-
vec!["libgopher_auth.so", "gopher_auth.so"]
197+
vec![
198+
"libgopher-orch.so",
199+
"libgopher-orch.so.0",
200+
"libgopher_orch.so",
201+
]
194202
};
195203

196-
// Try standard paths
197-
let search_paths = vec![
204+
// Build search paths including environment-specified locations
205+
let mut search_paths = vec![
198206
String::new(), // Current directory / system paths
199207
String::from("./"),
200-
String::from("/usr/local/lib/"),
201-
String::from("/usr/lib/"),
208+
String::from("./native/lib/"),
209+
String::from("../native/lib/"),
202210
];
203211

212+
// Add paths from DYLD_LIBRARY_PATH / LD_LIBRARY_PATH
213+
if let Ok(lib_path) = std::env::var("DYLD_LIBRARY_PATH") {
214+
for path in lib_path.split(':') {
215+
if !path.is_empty() {
216+
let mut p = path.to_string();
217+
if !p.ends_with('/') {
218+
p.push('/');
219+
}
220+
search_paths.push(p);
221+
}
222+
}
223+
}
224+
if let Ok(lib_path) = std::env::var("LD_LIBRARY_PATH") {
225+
for path in lib_path.split(':') {
226+
if !path.is_empty() {
227+
let mut p = path.to_string();
228+
if !p.ends_with('/') {
229+
p.push('/');
230+
}
231+
search_paths.push(p);
232+
}
233+
}
234+
}
235+
236+
// Add standard system paths
237+
search_paths.push(String::from("/usr/local/lib/"));
238+
search_paths.push(String::from("/usr/lib/"));
239+
204240
for path in &search_paths {
205241
for name in &lib_names {
206242
let full_path = format!("{}{}", path, name);
@@ -431,7 +467,7 @@ impl GopherAuthClient {
431467
unsafe {
432468
let set_option: Symbol<GopherAuthSetOptionFn> = self
433469
.library
434-
.get(b"gopher_auth_set_option\0")
470+
.get(b"gopher_auth_client_set_option\0")
435471
.map_err(|e| Error::auth(format!("Failed to load set_option: {}", e)))?;
436472

437473
let result = set_option(self.handle, key_c.as_ptr(), value_c.as_ptr());

0 commit comments

Comments
 (0)