mcp-postgresql-ops 3.1.5__tar.gz → 3.1.6__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 (17) hide show
  1. {mcp_postgresql_ops-3.1.5/src/mcp_postgresql_ops.egg-info → mcp_postgresql_ops-3.1.6}/PKG-INFO +5 -5
  2. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/README.md +4 -4
  3. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/pyproject.toml +1 -1
  4. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/src/mcp_postgresql_ops/mcp_main.py +23 -24
  5. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6/src/mcp_postgresql_ops.egg-info}/PKG-INFO +5 -5
  6. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/LICENSE +0 -0
  7. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/MANIFEST.in +0 -0
  8. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/setup.cfg +0 -0
  9. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/src/mcp_postgresql_ops/__init__.py +0 -0
  10. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/src/mcp_postgresql_ops/__main__.py +0 -0
  11. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/src/mcp_postgresql_ops/functions.py +0 -0
  12. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/src/mcp_postgresql_ops/version_compat.py +0 -0
  13. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/src/mcp_postgresql_ops.egg-info/SOURCES.txt +0 -0
  14. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/src/mcp_postgresql_ops.egg-info/dependency_links.txt +0 -0
  15. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/src/mcp_postgresql_ops.egg-info/entry_points.txt +0 -0
  16. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/src/mcp_postgresql_ops.egg-info/requires.txt +0 -0
  17. {mcp_postgresql_ops-3.1.5 → mcp_postgresql_ops-3.1.6}/src/mcp_postgresql_ops.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-postgresql-ops
3
- Version: 3.1.5
3
+ Version: 3.1.6
4
4
  Summary: Add your description here
5
5
  Author-email: JungJungIn <call518@gmail.com>
6
6
  Requires-Python: >=3.12
@@ -981,17 +981,17 @@ For `streamable-http` mode, this MCP server supports Bearer token authentication
981
981
  ```bash
982
982
  # In .env file
983
983
  REMOTE_AUTH_ENABLE=true
984
- REMOTE_SECRET_KEY=your-secure-secret-key-here
984
+ REMOTE_SECRET_KEY=my-test-secret-key-12345
985
985
  ```
986
986
 
987
987
  **Or via CLI:**
988
988
 
989
989
  ```bash
990
990
  # Module method
991
- python -m mcp_postgresql_ops --type streamable-http --auth-enable --secret-key your-secure-secret-key-here
991
+ python -m mcp_postgresql_ops --type streamable-http --auth-enable --secret-key my-test-secret-key-12345
992
992
 
993
993
  # Script method
994
- mcp-postgresql-ops --type streamable-http --auth-enable --secret-key your-secure-secret-key-here
994
+ mcp-postgresql-ops --type streamable-http --auth-enable --secret-key my-test-secret-key-12345
995
995
  ```
996
996
 
997
997
  #### Security Levels
@@ -1011,7 +1011,7 @@ When authentication is enabled, MCP clients must include the Bearer token in the
1011
1011
  "type": "streamable-http",
1012
1012
  "url": "http://your-server:8000/mcp",
1013
1013
  "headers": {
1014
- "Authorization": "Bearer your-secure-secret-key-here"
1014
+ "Authorization": "Bearer my-test-secret-key-12345"
1015
1015
  }
1016
1016
  }
1017
1017
  }
@@ -965,17 +965,17 @@ For `streamable-http` mode, this MCP server supports Bearer token authentication
965
965
  ```bash
966
966
  # In .env file
967
967
  REMOTE_AUTH_ENABLE=true
968
- REMOTE_SECRET_KEY=your-secure-secret-key-here
968
+ REMOTE_SECRET_KEY=my-test-secret-key-12345
969
969
  ```
970
970
 
971
971
  **Or via CLI:**
972
972
 
973
973
  ```bash
974
974
  # Module method
975
- python -m mcp_postgresql_ops --type streamable-http --auth-enable --secret-key your-secure-secret-key-here
975
+ python -m mcp_postgresql_ops --type streamable-http --auth-enable --secret-key my-test-secret-key-12345
976
976
 
977
977
  # Script method
978
- mcp-postgresql-ops --type streamable-http --auth-enable --secret-key your-secure-secret-key-here
978
+ mcp-postgresql-ops --type streamable-http --auth-enable --secret-key my-test-secret-key-12345
979
979
  ```
980
980
 
981
981
  #### Security Levels
@@ -995,7 +995,7 @@ When authentication is enabled, MCP clients must include the Bearer token in the
995
995
  "type": "streamable-http",
996
996
  "url": "http://your-server:8000/mcp",
997
997
  "headers": {
998
- "Authorization": "Bearer your-secure-secret-key-here"
998
+ "Authorization": "Bearer my-test-secret-key-12345"
999
999
  }
1000
1000
  }
1001
1001
  }
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mcp-postgresql-ops"
3
- version = "3.1.5"
3
+ version = "3.1.6"
4
4
  description = "Add your description here"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -63,30 +63,27 @@ logging.basicConfig(
63
63
  # Authentication Setup
64
64
  # =============================================================================
65
65
 
66
- # Check environment variables for authentication early
67
- _auth_enable = os.environ.get("REMOTE_AUTH_ENABLE", "false").lower() == "true"
68
- _secret_key = os.environ.get("REMOTE_SECRET_KEY", "")
66
+ TRUTHY_VALUES = ("true", "1", "yes", "on")
69
67
 
70
- # Initialize the main MCP instance with authentication if configured
71
- if _auth_enable and _secret_key:
72
- logger.info("Initializing MCP instance with Bearer token authentication (from environment)")
73
-
74
- # Create token configuration
68
+
69
+ def _parse_bool_env(value: str) -> bool:
70
+ return value.strip().lower() in TRUTHY_VALUES
71
+
72
+
73
+ def _build_static_token_auth(secret_key: str) -> StaticTokenVerifier:
75
74
  tokens = {
76
- _secret_key: {
75
+ secret_key: {
77
76
  "client_id": "postgresql-ops-client",
78
- "user": "admin",
79
77
  "scopes": ["read", "write"],
80
- "description": "PostgreSQL Operations access token"
81
78
  }
82
79
  }
83
-
84
- auth = StaticTokenVerifier(tokens=tokens)
85
- mcp = FastMCP("mcp-postgresql-ops", auth=auth)
86
- logger.info("MCP instance initialized with authentication")
87
- else:
88
- logger.info("Initializing MCP instance without authentication")
89
- mcp = FastMCP("mcp-postgresql-ops")
80
+ return StaticTokenVerifier(tokens=tokens)
81
+
82
+
83
+ # Initialize MCP instance once for decorator registration.
84
+ # Runtime authentication is configured in main() before mcp.run().
85
+ logger.info("Initializing MCP instance")
86
+ mcp = FastMCP("mcp-postgresql-ops")
90
87
 
91
88
  # =============================================================================
92
89
  # Server initialization
@@ -3684,7 +3681,9 @@ def main(argv: Optional[list] = None) -> None:
3684
3681
  port = args.port or int(os.getenv("FASTMCP_PORT", "8000"))
3685
3682
 
3686
3683
  # Authentication settings
3687
- auth_enable = args.auth_enable or os.getenv("REMOTE_AUTH_ENABLE", "false").lower() in ("true", "1", "yes", "on")
3684
+ auth_enable = args.auth_enable or _parse_bool_env(
3685
+ os.getenv("REMOTE_AUTH_ENABLE", "false")
3686
+ )
3688
3687
  secret_key = args.secret_key or os.getenv("REMOTE_SECRET_KEY", "")
3689
3688
 
3690
3689
  # Validation for streamable-http mode with authentication
@@ -3700,11 +3699,11 @@ def main(argv: Optional[list] = None) -> None:
3700
3699
  logger.warning("This server will accept requests without Bearer token verification.")
3701
3700
  logger.warning("Set REMOTE_AUTH_ENABLE=true and REMOTE_SECRET_KEY to enable authentication.")
3702
3701
 
3703
- # Note: MCP instance with authentication is already initialized at module level
3704
- # based on environment variables. CLI arguments will override if different.
3705
- if auth_enable != _auth_enable or secret_key != _secret_key:
3706
- logger.warning("CLI authentication settings differ from environment variables.")
3707
- logger.warning("Environment settings take precedence during module initialization.")
3702
+ # Configure authentication provider before server startup.
3703
+ if auth_enable:
3704
+ mcp.auth = _build_static_token_auth(secret_key)
3705
+ else:
3706
+ mcp.auth = None
3708
3707
 
3709
3708
  # Debug logging for environment variables
3710
3709
  logger.debug(f"Environment variables - POSTGRES_HOST: {os.getenv('POSTGRES_HOST')}, POSTGRES_PORT: {os.getenv('POSTGRES_PORT')}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-postgresql-ops
3
- Version: 3.1.5
3
+ Version: 3.1.6
4
4
  Summary: Add your description here
5
5
  Author-email: JungJungIn <call518@gmail.com>
6
6
  Requires-Python: >=3.12
@@ -981,17 +981,17 @@ For `streamable-http` mode, this MCP server supports Bearer token authentication
981
981
  ```bash
982
982
  # In .env file
983
983
  REMOTE_AUTH_ENABLE=true
984
- REMOTE_SECRET_KEY=your-secure-secret-key-here
984
+ REMOTE_SECRET_KEY=my-test-secret-key-12345
985
985
  ```
986
986
 
987
987
  **Or via CLI:**
988
988
 
989
989
  ```bash
990
990
  # Module method
991
- python -m mcp_postgresql_ops --type streamable-http --auth-enable --secret-key your-secure-secret-key-here
991
+ python -m mcp_postgresql_ops --type streamable-http --auth-enable --secret-key my-test-secret-key-12345
992
992
 
993
993
  # Script method
994
- mcp-postgresql-ops --type streamable-http --auth-enable --secret-key your-secure-secret-key-here
994
+ mcp-postgresql-ops --type streamable-http --auth-enable --secret-key my-test-secret-key-12345
995
995
  ```
996
996
 
997
997
  #### Security Levels
@@ -1011,7 +1011,7 @@ When authentication is enabled, MCP clients must include the Bearer token in the
1011
1011
  "type": "streamable-http",
1012
1012
  "url": "http://your-server:8000/mcp",
1013
1013
  "headers": {
1014
- "Authorization": "Bearer your-secure-secret-key-here"
1014
+ "Authorization": "Bearer my-test-secret-key-12345"
1015
1015
  }
1016
1016
  }
1017
1017
  }