Tracy André commited on
Commit
c561fce
·
1 Parent(s): 4d340aa
Files changed (1) hide show
  1. mcp_server.py +11 -11
mcp_server.py CHANGED
@@ -93,7 +93,7 @@ analyzer = WeedPressureAnalyzer()
93
  # These functions provide structured data access for LLMs and can be exposed as MCP resources
94
  # To activate: uncomment the @gr.mcp.resource decorators below
95
 
96
- # @gr.mcp.resource("agricultural://plots")
97
  def get_available_plots_resource() -> str:
98
  """Get list of all available agricultural plots from the dataset"""
99
  try:
@@ -102,7 +102,7 @@ def get_available_plots_resource() -> str:
102
  except Exception as e:
103
  return f"Error loading plots: {str(e)}"
104
 
105
- # @gr.mcp.resource("agricultural://crops")
106
  def get_available_crops_resource() -> str:
107
  """Get list of all crop types in the dataset"""
108
  try:
@@ -111,7 +111,7 @@ def get_available_crops_resource() -> str:
111
  except Exception as e:
112
  return f"Error loading crops: {str(e)}"
113
 
114
- # @gr.mcp.resource("agricultural://years")
115
  def get_available_years_resource() -> str:
116
  """Get range of years available in the dataset"""
117
  try:
@@ -121,7 +121,7 @@ def get_available_years_resource() -> str:
121
  except Exception as e:
122
  return f"Error loading years: {str(e)}"
123
 
124
- # @gr.mcp.resource("agricultural://dataset-info")
125
  def get_dataset_info() -> str:
126
  """Get comprehensive information about the agricultural dataset"""
127
  try:
@@ -144,7 +144,7 @@ Agricultural Dataset Information:
144
  except Exception as e:
145
  return f"Error loading dataset info: {str(e)}"
146
 
147
- # @gr.mcp.resource("agricultural://plot/{plot_name}")
148
  def get_plot_info(plot_name: str) -> str:
149
  """Get detailed information about a specific agricultural plot"""
150
  try:
@@ -171,7 +171,7 @@ Plot Information: {plot_name}
171
  except Exception as e:
172
  return f"Error loading plot info: {str(e)}"
173
 
174
- # @gr.mcp.resource("agricultural://crop/{crop_type}")
175
  def get_crop_info(crop_type: str) -> str:
176
  """Get information about a specific crop type and its cultivation patterns"""
177
  try:
@@ -199,7 +199,7 @@ Crop Information: {crop_type}
199
  except Exception as e:
200
  return f"Error loading crop info: {str(e)}"
201
 
202
- # @gr.mcp.resource("agricultural://year/{year}")
203
  def get_year_summary(year: int) -> str:
204
  """Get summary of agricultural activities for a specific year"""
205
  try:
@@ -228,7 +228,7 @@ Year Summary: {year}
228
  except Exception as e:
229
  return f"Error loading year summary: {str(e)}"
230
 
231
- # @gr.mcp.resource("agricultural://herbicide-usage")
232
  def get_herbicide_usage_summary() -> str:
233
  """Get comprehensive summary of herbicide usage patterns"""
234
  try:
@@ -268,7 +268,7 @@ Herbicide Usage Summary:
268
  except Exception as e:
269
  return f"Error loading herbicide usage summary: {str(e)}"
270
 
271
- # @gr.mcp.resource("agricultural://predictions/2025-2027")
272
  def get_predictions_summary() -> str:
273
  """Get summary of weed pressure predictions for 2025-2027"""
274
  try:
@@ -298,7 +298,7 @@ Weed Pressure Predictions 2025-2027:
298
  except Exception as e:
299
  return f"Error loading predictions summary: {str(e)}"
300
 
301
- # @gr.mcp.resource("agricultural://recommendations/sensitive-crops")
302
  def get_recommendations_summary() -> str:
303
  """Get summary of plot recommendations for sensitive crops (pois, haricot)"""
304
  try:
@@ -331,7 +331,7 @@ Sensitive Crop Recommendations (Pois, Haricot):
331
  except Exception as e:
332
  return f"Error loading recommendations summary: {str(e)}"
333
 
334
- # @gr.mcp.resource("agricultural://plot/{plot_name}/predictions")
335
  def get_plot_predictions(plot_name: str) -> str:
336
  """Get weed pressure predictions for a specific plot"""
337
  try:
 
93
  # These functions provide structured data access for LLMs and can be exposed as MCP resources
94
  # To activate: uncomment the @gr.mcp.resource decorators below
95
 
96
+ @gr.mcp.resource("agricultural://plots")
97
  def get_available_plots_resource() -> str:
98
  """Get list of all available agricultural plots from the dataset"""
99
  try:
 
102
  except Exception as e:
103
  return f"Error loading plots: {str(e)}"
104
 
105
+ @gr.mcp.resource("agricultural://crops")
106
  def get_available_crops_resource() -> str:
107
  """Get list of all crop types in the dataset"""
108
  try:
 
111
  except Exception as e:
112
  return f"Error loading crops: {str(e)}"
113
 
114
+ @gr.mcp.resource("agricultural://years")
115
  def get_available_years_resource() -> str:
116
  """Get range of years available in the dataset"""
117
  try:
 
121
  except Exception as e:
122
  return f"Error loading years: {str(e)}"
123
 
124
+ @gr.mcp.resource("agricultural://dataset-info")
125
  def get_dataset_info() -> str:
126
  """Get comprehensive information about the agricultural dataset"""
127
  try:
 
144
  except Exception as e:
145
  return f"Error loading dataset info: {str(e)}"
146
 
147
+ @gr.mcp.resource("agricultural://plot/{plot_name}")
148
  def get_plot_info(plot_name: str) -> str:
149
  """Get detailed information about a specific agricultural plot"""
150
  try:
 
171
  except Exception as e:
172
  return f"Error loading plot info: {str(e)}"
173
 
174
+ @gr.mcp.resource("agricultural://crop/{crop_type}")
175
  def get_crop_info(crop_type: str) -> str:
176
  """Get information about a specific crop type and its cultivation patterns"""
177
  try:
 
199
  except Exception as e:
200
  return f"Error loading crop info: {str(e)}"
201
 
202
+ @gr.mcp.resource("agricultural://year/{year}")
203
  def get_year_summary(year: int) -> str:
204
  """Get summary of agricultural activities for a specific year"""
205
  try:
 
228
  except Exception as e:
229
  return f"Error loading year summary: {str(e)}"
230
 
231
+ @gr.mcp.resource("agricultural://herbicide-usage")
232
  def get_herbicide_usage_summary() -> str:
233
  """Get comprehensive summary of herbicide usage patterns"""
234
  try:
 
268
  except Exception as e:
269
  return f"Error loading herbicide usage summary: {str(e)}"
270
 
271
+ @gr.mcp.resource("agricultural://predictions/2025-2027")
272
  def get_predictions_summary() -> str:
273
  """Get summary of weed pressure predictions for 2025-2027"""
274
  try:
 
298
  except Exception as e:
299
  return f"Error loading predictions summary: {str(e)}"
300
 
301
+ @gr.mcp.resource("agricultural://recommendations/sensitive-crops")
302
  def get_recommendations_summary() -> str:
303
  """Get summary of plot recommendations for sensitive crops (pois, haricot)"""
304
  try:
 
331
  except Exception as e:
332
  return f"Error loading recommendations summary: {str(e)}"
333
 
334
+ @gr.mcp.resource("agricultural://plot/{plot_name}/predictions")
335
  def get_plot_predictions(plot_name: str) -> str:
336
  """Get weed pressure predictions for a specific plot"""
337
  try: