Skip to content

Commit 60a7422

Browse files
committed
fix(library): restore dropped Postgres MCP FAQs and make the tenant policy fail closed on malformed context
1 parent e7f6b3c commit 60a7422

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

  • apps/sim/content/library/postgres-mcp-server-ai-agents

‎apps/sim/content/library/postgres-mcp-server-ai-agents/index.mdx‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ faq:
4242
a: "Sim's core is open source under the Apache License 2.0, while apps/sim/ee is governed by the separate Sim Enterprise License. Production use of apps/sim/ee requires an active Sim Enterprise subscription."
4343
- q: "Is n8n open source?"
4444
a: "n8n is source available under the Sustainable Use License, which is not an OSI-approved open-source license."
45+
- q: "Is Sim or n8n better for Postgres MCP?"
46+
a: "Sim fits teams that need to build, deploy, and manage AI agents around governed MCP tools, while n8n fits teams adding external MCP tools to an existing n8n automation environment. In either architecture, PostgreSQL still needs its own read-only role, row-level security, timeouts, and audit controls."
47+
- q: "What is the best AI agent builder for Postgres MCP?"
48+
a: "Sim is a strong AI agent platform to evaluate for Postgres MCP, while the broader Best AI Agent Platforms and Builders in 2026 guide compares the full head-term market."
4549
- q: "What is the difference between a Postgres connector and a Postgres MCP server?"
4650
a: "A Postgres connector gives one platform a predefined database integration, while a Postgres MCP server exposes structured tools through a protocol that compatible MCP clients can consume."
4751
- q: "Can one Postgres MCP server be shared by multiple AI agents?"
@@ -185,13 +189,25 @@ A representative policy can use a transaction-scoped setting:
185189
ALTER TABLE agent_memory ENABLE ROW LEVEL SECURITY;
186190
ALTER TABLE agent_memory FORCE ROW LEVEL SECURITY;
187191

192+
CREATE FUNCTION app_current_tenant_id() RETURNS uuid
193+
LANGUAGE sql STABLE
194+
AS $$
195+
SELECT CASE
196+
WHEN setting ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'
197+
THEN setting::uuid
198+
END
199+
FROM (SELECT current_setting('app.tenant_id', true) AS setting) AS tenant_context;
200+
$$;
201+
188202
CREATE POLICY agent_memory_tenant_policy
189203
ON agent_memory
190204
FOR SELECT
191205
TO agent_reader
192-
USING (tenant_id = current_setting('app.tenant_id', true)::uuid);
206+
USING (tenant_id = app_current_tenant_id());
193207
```
194208

209+
The helper returns `NULL` when the setting is missing, empty, or not a UUID, so the policy matches no rows instead of raising a cast error.
210+
195211
Use this tenant-isolation checklist:
196212

197213
1. Derive tenant identity from authenticated server-side context, never from a model argument.

0 commit comments

Comments
 (0)