awslabs.postgres-mcp-server 0.0.5__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/Dockerfile +11 -8
  2. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/PKG-INFO +1 -1
  3. awslabs_postgres_mcp_server-1.0.1/awslabs/__init__.py +16 -0
  4. awslabs_postgres_mcp_server-1.0.1/awslabs/postgres_mcp_server/__init__.py +17 -0
  5. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/awslabs/postgres_mcp_server/mutable_sql_detector.py +10 -9
  6. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/awslabs/postgres_mcp_server/server.py +11 -15
  7. awslabs_postgres_mcp_server-1.0.1/docker-healthcheck.sh +26 -0
  8. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/pyproject.toml +1 -1
  9. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/tests/test_server.py +16 -7
  10. awslabs_postgres_mcp_server-0.0.5/awslabs/__init__.py +0 -13
  11. awslabs_postgres_mcp_server-0.0.5/awslabs/postgres_mcp_server/__init__.py +0 -14
  12. awslabs_postgres_mcp_server-0.0.5/docker-healthcheck.sh +0 -12
  13. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/.gitignore +0 -0
  14. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/.pre-commit-config.yaml +0 -0
  15. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/.python-version +0 -0
  16. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/CHANGELOG.md +0 -0
  17. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/LICENSE +0 -0
  18. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/NOTICE +0 -0
  19. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/README.md +0 -0
  20. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/tests/conftest.py +0 -0
  21. {awslabs_postgres_mcp_server-0.0.5 → awslabs_postgres_mcp_server-1.0.1}/uv.lock +0 -0
@@ -1,16 +1,19 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
- # with the License. A copy of the License is located at
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
8
- # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
- # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
- # and limitations under the License.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
 
12
15
  #FROM public.ecr.aws/sam/build-python3.10:1.137.1-20250411084548
13
- FROM public.ecr.aws/sam/build-python3.10@sha256:a40f492a0cd8d76557f8a187fc00e49e8864b3cea683e74718ce317790c1ce61 AS uv
16
+ FROM public.ecr.aws/sam/build-python3.10@sha256:e78695db10ca8cb129e59e30f7dc9789b0dbd0181dba195d68419c72bac51ac1 AS uv
14
17
 
15
18
  # Install the project into `/app`
16
19
  WORKDIR /app
@@ -44,7 +47,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
44
47
  # Make the directory just in case it doesn't exist
45
48
  RUN mkdir -p /root/.local
46
49
 
47
- FROM public.ecr.aws/sam/build-python3.10@sha256:a40f492a0cd8d76557f8a187fc00e49e8864b3cea683e74718ce317790c1ce61
50
+ FROM public.ecr.aws/sam/build-python3.10@sha256:e78695db10ca8cb129e59e30f7dc9789b0dbd0181dba195d68419c72bac51ac1
48
51
 
49
52
  # Place executables in the environment at the front of the path and include other binaries
50
53
  ENV PATH="/app/.venv/bin:$PATH:/usr/sbin"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: awslabs.postgres-mcp-server
3
- Version: 0.0.5
3
+ Version: 1.0.1
4
4
  Summary: An AWS Labs Model Context Protocol (MCP) server for postgres
5
5
  Project-URL: homepage, https://awslabs.github.io/mcp/
6
6
  Project-URL: docs, https://awslabs.github.io/mcp/servers/postgres-mcp-server/
@@ -0,0 +1,16 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # This file is part of the awslabs namespace.
16
+ # It is intentionally minimal to support PEP 420 namespace packages.
@@ -0,0 +1,17 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """awslabs.postgres-mcp-server"""
16
+
17
+ __version__ = '0.0.4'
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
- # with the License. A copy of the License is located at
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
8
- # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
- # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
- # and limitations under the License.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
 
12
15
  import re
13
16
 
@@ -47,8 +50,6 @@ MUTATING_PATTERN = re.compile(
47
50
  )
48
51
 
49
52
  SUSPICIOUS_PATTERNS = [
50
- r'--.*$', # single-line comment
51
- r'/\*.*?\*/', # multi-line comment
52
53
  r"(?i)'.*?--", # comment injection
53
54
  r'(?i)\bor\b\s+\d+\s*=\s*\d+', # numeric tautology e.g. OR 1=1
54
55
  r"(?i)\bor\b\s*'[^']+'\s*=\s*'[^']+'", # string tautology e.g. OR '1'='1'
@@ -56,7 +57,7 @@ SUSPICIOUS_PATTERNS = [
56
57
  r'(?i)\bdrop\b', # DROP statement
57
58
  r'(?i)\btruncate\b', # TRUNCATE
58
59
  r'(?i)\bgrant\b|\brevoke\b', # GRANT or REVOKE
59
- r'(?i);', # stacked queries
60
+ r';\s*(?!($|\s*--|\s*/\*))(?=\S)', # stacked queries, excluding semicolons followed by comments or whitespace
60
61
  r'(?i)\bsleep\s*\(', # delay-based probes
61
62
  r'(?i)\bpg_sleep\s*\(',
62
63
  r'(?i)\bload_file\s*\(',
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
- # with the License. A copy of the License is located at
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
8
- # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
- # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
- # and limitations under the License.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
 
12
15
  """awslabs postgres MCP Server implementation."""
13
16
 
@@ -372,8 +375,6 @@ def main():
372
375
  parser = argparse.ArgumentParser(
373
376
  description='An AWS Labs Model Context Protocol (MCP) server for postgres'
374
377
  )
375
- parser.add_argument('--sse', action='store_true', help='Use SSE transport')
376
- parser.add_argument('--port', type=int, default=8888, help='Port to run the server on')
377
378
  parser.add_argument('--resource_arn', required=True, help='ARN of the RDS cluster')
378
379
  parser.add_argument(
379
380
  '--secret_arn',
@@ -420,13 +421,8 @@ def main():
420
421
 
421
422
  logger.success('Successfully validated RDS API db connection to Postgres')
422
423
 
423
- # Run server with appropriate transport
424
- if args.sse:
425
- mcp.settings.port = args.port
426
- mcp.run(transport='sse')
427
- else:
428
- logger.info('Starting Postgres MCP server')
429
- mcp.run()
424
+ logger.info('Starting Postgres MCP server')
425
+ mcp.run()
430
426
 
431
427
 
432
428
  if __name__ == '__main__':
@@ -0,0 +1,26 @@
1
+ #!/bin/sh
2
+
3
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ if [ "$(lsof +c 0 -p 1 | grep -e "^awslabs\..*\s1\s.*\sunix\s.*socket$" | wc -l)" -ne "0" ]; then
18
+ echo -n "$(lsof +c 0 -p 1 | grep -e "^awslabs\..*\s1\s.*\sunix\s.*socket$" | wc -l) awslabs.* streams found";
19
+ exit 0;
20
+ else
21
+ echo -n "Zero awslabs.* streams found";
22
+ exit 1;
23
+ fi;
24
+
25
+ echo -n "Never should reach here";
26
+ exit 99;
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "awslabs.postgres-mcp-server"
3
- version = "0.0.5"
3
+ version = "1.0.1"
4
4
  description = "An AWS Labs Model Context Protocol (MCP) server for postgres"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -1,13 +1,16 @@
1
1
  # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
- # with the License. A copy of the License is located at
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
5
6
  #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
7
8
  #
8
- # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
- # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
- # and limitations under the License.
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
11
14
  """Tests for the postgres MCP Server."""
12
15
 
13
16
  import asyncio
@@ -31,8 +34,14 @@ from conftest import DummyCtx, Mock_DBConnection, MockException
31
34
 
32
35
  SAFE_READONLY_QUERIES = [
33
36
  # Basic SELECT Queries
34
- # 1. Simple SELECT
37
+ # 1a. Simple SELECT
35
38
  'SELECT * FROM employees',
39
+ # 1b. Simple SELECT with trailing semicolon
40
+ 'SELECT * FROM employees;',
41
+ # 1c. Simple SELECT with trailing semicolon and comment
42
+ 'SELECT * FROM employees; -- This is a comment',
43
+ # 1d. Simple SELECT with trailing semicolon and multi line comment
44
+ 'SELECT * FROM employees; /* This is a comment */',
36
45
  # 2. SELECT with WHERE
37
46
  """SELECT first_name, last_name, salary
38
47
  FROM employees
@@ -1,13 +0,0 @@
1
- # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
- # with the License. A copy of the License is located at
5
- #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
- #
8
- # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
- # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
- # and limitations under the License.
11
-
12
- # This file is part of the awslabs namespace.
13
- # It is intentionally minimal to support PEP 420 namespace packages.
@@ -1,14 +0,0 @@
1
- # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
4
- # with the License. A copy of the License is located at
5
- #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
- #
8
- # or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
9
- # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
10
- # and limitations under the License.
11
-
12
- """awslabs.postgres-mcp-server"""
13
-
14
- __version__ = '0.0.3'
@@ -1,12 +0,0 @@
1
- #!/bin/sh
2
-
3
- if [ "$(lsof +c 0 -p 1 | grep -e "^awslabs\..*\s1\s.*\sunix\s.*socket$" | wc -l)" -ne "0" ]; then
4
- echo -n "$(lsof +c 0 -p 1 | grep -e "^awslabs\..*\s1\s.*\sunix\s.*socket$" | wc -l) awslabs.* streams found";
5
- exit 0;
6
- else
7
- echo -n "Zero awslabs.* streams found";
8
- exit 1;
9
- fi;
10
-
11
- echo -n "Never should reach here";
12
- exit 99;