Skip to content

Conversation

alocay
Copy link
Contributor

@alocay alocay commented Aug 18, 2025

Initial attempt at moving out serving the server from the state machine. Still a work in progress and needs testing.

@apollo-librarian
Copy link

apollo-librarian bot commented Aug 18, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 1 changed, 0 removed
* (developer-tools)/apollo-mcp-server/(latest)/guides/auth.mdx

Build ID: 81e0d94058650c32a719e90e
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/81e0d94058650c32a719e90e

Copy link

Changeset file missing for PR

All changes should include an associated changeset file.
Please refer to README for more information on generating changesets.

@alocay alocay changed the base branch from main to develop August 18, 2025 14:51
use tracing::{Instrument, error, info, trace};

// Helper to enable auth
macro_rules! with_auth {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless we are going to disable/modify this macro based on feature flags I would just move this to a function.


// Create health check if enabled (only for StreamableHttp transport)
fn create_health_check(config: HealthCheckConfig) -> Option<HealthCheck> {
// let telemetry: Arc<dyn Telemetry> = Arc::new(InMemoryTelemetry::new());
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

@alocay alocay Aug 18, 2025

Choose a reason for hiding this comment

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

This is left over from a previous change I was doing, ignore it for now.

}};
}

pub struct Serve;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: The Serve name here is a little confusing as verbs are usually Traits in rust.

.with_graceful_shutdown(shutdown_signal())
.await
{
// This can never really happen
Copy link
Contributor

Choose a reason for hiding this comment

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

Why cant this happen? If it is really impossible we should mark it as unreachable!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just copied over from what was there. I'd have to take a look to see what this comment was referring to.


let (server, router) = SseServer::new(SseServerConfig {
bind: listen_address,
sse_path: "/sse".to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Implement Default for SseServerConfig then this can be reduced to:

SseServerConfig {
   bind: listen_address, 
   ct: canellation_token,
   ..Default::default()
}

serde_json::to_string_pretty(&updated_operations)?
);
*self.operations.lock().await = updated_operations;
*self.server_handler.write().await.operations().lock().await = updated_operations;
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment above on the overall write lock


// Notify MCP clients that tools have changed
Self::notify_tool_list_changed(self.peers.clone()).await;
self.server_handler
Copy link
Contributor

Choose a reason for hiding this comment

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

Thought: I wonder if we could move all the mutable state into an inner RwLock object. Then you wouldnt might have some set of state that is readable cross-thread without the lock.

use crate::health::HealthCheckConfig;

/// Common configuration options for the server
pub struct ServerConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I missed how this is created, but it seems odd to me that this doesnt impl Deserialize?

self.headers.clone()
}

fn endpoint(&self) -> Url {
Copy link
Contributor

Choose a reason for hiding this comment

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

If these are public, should we even expose the fields in the struct via pub(crate)?

self.validate_tool.clone()
}

fn peers(&self) -> Arc<RwLock<Vec<Peer<RoleServer>>>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is quite a type signature lol

Copy link

Changeset file missing for PR

All changes should include an associated changeset file.
Please refer to README for more information on generating changesets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants