d365fo-client 0.2.4__py3-none-any.whl → 0.3.1__py3-none-any.whl

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 (59) hide show
  1. d365fo_client/__init__.py +7 -1
  2. d365fo_client/auth.py +9 -21
  3. d365fo_client/cli.py +25 -13
  4. d365fo_client/client.py +8 -4
  5. d365fo_client/config.py +52 -30
  6. d365fo_client/credential_sources.py +5 -0
  7. d365fo_client/main.py +1 -1
  8. d365fo_client/mcp/__init__.py +3 -1
  9. d365fo_client/mcp/auth_server/__init__.py +5 -0
  10. d365fo_client/mcp/auth_server/auth/__init__.py +30 -0
  11. d365fo_client/mcp/auth_server/auth/auth.py +372 -0
  12. d365fo_client/mcp/auth_server/auth/oauth_proxy.py +989 -0
  13. d365fo_client/mcp/auth_server/auth/providers/__init__.py +0 -0
  14. d365fo_client/mcp/auth_server/auth/providers/apikey.py +83 -0
  15. d365fo_client/mcp/auth_server/auth/providers/azure.py +393 -0
  16. d365fo_client/mcp/auth_server/auth/providers/bearer.py +25 -0
  17. d365fo_client/mcp/auth_server/auth/providers/jwt.py +547 -0
  18. d365fo_client/mcp/auth_server/auth/redirect_validation.py +65 -0
  19. d365fo_client/mcp/auth_server/dependencies.py +136 -0
  20. d365fo_client/mcp/client_manager.py +16 -67
  21. d365fo_client/mcp/fastmcp_main.py +407 -0
  22. d365fo_client/mcp/fastmcp_server.py +598 -0
  23. d365fo_client/mcp/fastmcp_utils.py +431 -0
  24. d365fo_client/mcp/main.py +40 -13
  25. d365fo_client/mcp/mixins/__init__.py +24 -0
  26. d365fo_client/mcp/mixins/base_tools_mixin.py +55 -0
  27. d365fo_client/mcp/mixins/connection_tools_mixin.py +50 -0
  28. d365fo_client/mcp/mixins/crud_tools_mixin.py +311 -0
  29. d365fo_client/mcp/mixins/database_tools_mixin.py +685 -0
  30. d365fo_client/mcp/mixins/label_tools_mixin.py +87 -0
  31. d365fo_client/mcp/mixins/metadata_tools_mixin.py +565 -0
  32. d365fo_client/mcp/mixins/performance_tools_mixin.py +109 -0
  33. d365fo_client/mcp/mixins/profile_tools_mixin.py +713 -0
  34. d365fo_client/mcp/mixins/sync_tools_mixin.py +321 -0
  35. d365fo_client/mcp/prompts/action_execution.py +1 -1
  36. d365fo_client/mcp/prompts/sequence_analysis.py +1 -1
  37. d365fo_client/mcp/tools/crud_tools.py +3 -3
  38. d365fo_client/mcp/tools/sync_tools.py +1 -1
  39. d365fo_client/mcp/utilities/__init__.py +1 -0
  40. d365fo_client/mcp/utilities/auth.py +34 -0
  41. d365fo_client/mcp/utilities/logging.py +58 -0
  42. d365fo_client/mcp/utilities/types.py +426 -0
  43. d365fo_client/metadata_v2/sync_manager_v2.py +2 -0
  44. d365fo_client/metadata_v2/sync_session_manager.py +7 -7
  45. d365fo_client/models.py +139 -139
  46. d365fo_client/output.py +2 -2
  47. d365fo_client/profile_manager.py +62 -27
  48. d365fo_client/profiles.py +118 -113
  49. d365fo_client/settings.py +367 -0
  50. d365fo_client/sync_models.py +85 -2
  51. d365fo_client/utils.py +2 -1
  52. {d365fo_client-0.2.4.dist-info → d365fo_client-0.3.1.dist-info}/METADATA +273 -18
  53. d365fo_client-0.3.1.dist-info/RECORD +85 -0
  54. d365fo_client-0.3.1.dist-info/entry_points.txt +4 -0
  55. d365fo_client-0.2.4.dist-info/RECORD +0 -56
  56. d365fo_client-0.2.4.dist-info/entry_points.txt +0 -3
  57. {d365fo_client-0.2.4.dist-info → d365fo_client-0.3.1.dist-info}/WHEEL +0 -0
  58. {d365fo_client-0.2.4.dist-info → d365fo_client-0.3.1.dist-info}/licenses/LICENSE +0 -0
  59. {d365fo_client-0.2.4.dist-info → d365fo_client-0.3.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,109 @@
1
+ """Performance tools mixin for FastMCP server."""
2
+
3
+ import json
4
+ import logging
5
+ from datetime import datetime
6
+
7
+ from .base_tools_mixin import BaseToolsMixin
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+
12
+ class PerformanceToolsMixin(BaseToolsMixin):
13
+ """Performance monitoring and configuration tools for FastMCP server."""
14
+
15
+ def register_performance_tools(self):
16
+ """Register all performance tools with FastMCP."""
17
+
18
+ @self.mcp.tool()
19
+ async def d365fo_get_server_performance() -> dict:
20
+ """Get FastMCP server performance statistics and health metrics.
21
+
22
+ Returns:
23
+ Dict with server performance data
24
+ """
25
+ try:
26
+ performance_stats = self.get_performance_stats()
27
+
28
+ # Add client manager health stats
29
+ client_health = await self.client_manager.health_check()
30
+
31
+ return {
32
+ "server_performance": performance_stats,
33
+ "client_health": client_health,
34
+ "timestamp": datetime.now().isoformat(),
35
+ }
36
+
37
+ except Exception as e:
38
+ logger.error(f"Get server performance failed: {e}")
39
+ return {"error": str(e)}
40
+
41
+ @self.mcp.tool()
42
+ async def d365fo_reset_performance_stats() -> dict:
43
+ """Reset server performance statistics.
44
+
45
+ Returns:
46
+ Dict with reset confirmation
47
+ """
48
+ try:
49
+ # Reset performance stats
50
+ self._request_stats = {
51
+ "total_requests": 0,
52
+ "total_errors": 0,
53
+ "avg_response_time": 0.0,
54
+ "last_reset": datetime.now(),
55
+ }
56
+ self._request_times = []
57
+ self._connection_pool_stats = {
58
+ "active_connections": 0,
59
+ "peak_connections": 0,
60
+ "connection_errors": 0,
61
+ "pool_hits": 0,
62
+ "pool_misses": 0,
63
+ }
64
+
65
+ # Clean up expired sessions
66
+ self._cleanup_expired_sessions()
67
+
68
+ return {
69
+ "performance_stats_reset": True,
70
+ "reset_timestamp": datetime.now().isoformat(),
71
+ }
72
+
73
+ except Exception as e:
74
+ logger.error(f"Reset performance stats failed: {e}")
75
+ return {"error": str(e), "reset_successful": False}
76
+
77
+ @self.mcp.tool()
78
+ async def d365fo_get_server_config() -> dict:
79
+ """Get current FastMCP server configuration and feature status.
80
+
81
+ Returns:
82
+ Dict with server configuration
83
+ """
84
+ try:
85
+ from ... import __version__
86
+
87
+ config_info = {
88
+ "server_version": __version__,
89
+ "stateless_mode": self._stateless_mode,
90
+ "json_response_mode": self._json_response_mode,
91
+ "max_concurrent_requests": self._max_concurrent_requests,
92
+ "request_timeout": self._request_timeout,
93
+ "batch_size": self._batch_size,
94
+ "transport_config": self.config.get("server", {}).get(
95
+ "transport", {}
96
+ ),
97
+ "performance_config": self.config.get("performance", {}),
98
+ "cache_config": self.config.get("cache", {}),
99
+ "security_config": self.config.get("security", {}),
100
+ }
101
+
102
+ return {
103
+ "server_config": config_info,
104
+ "timestamp": datetime.now().isoformat(),
105
+ }
106
+
107
+ except Exception as e:
108
+ logger.error(f"Get server config failed: {e}")
109
+ return {"error": str(e)}