Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(pgapi): pass allowed hosts to the MCP transport's DNS-rebinding guard (#95540)

Nick Best7a2c6545d621
diff --git a/rust/pgapi/src/mcp.rs b/rust/pgapi/src/mcp.rs
index 0d76ba4f751d..3a9901320c4d 100644
--- a/rust/pgapi/src/mcp.rs
+++ b/rust/pgapi/src/mcp.rs
@@ -348,9 +348,15 @@ impl ServerHandler for PgMcp {
}
pub fn service(state: Arc<AppState>) -> StreamableHttpService<PgMcp, LocalSessionManager> {
+ let mut config = StreamableHttpServerConfig::default();
+ if state.allowed_hosts.is_empty() {
+ config = config.disable_allowed_hosts();
+ } else {
+ config = config.with_allowed_hosts(state.allowed_hosts.clone());
+ }
StreamableHttpService::new(
move || Ok(PgMcp::new(state.clone())),
LocalSessionManager::default().into(),
- StreamableHttpServerConfig::default(),
+ config,
)
}