ApiLogicServer 14.5.17__py3-none-any.whl → 15.0.9__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 (39) hide show
  1. api_logic_server_cli/add_cust/add_cust.py +8 -2
  2. api_logic_server_cli/api_logic_server.py +3 -2
  3. api_logic_server_cli/api_logic_server_info.yaml +3 -3
  4. api_logic_server_cli/create_from_model/__pycache__/dbml.cpython-312.pyc +0 -0
  5. api_logic_server_cli/create_from_model/dbml.py +1 -0
  6. api_logic_server_cli/genai/genai_svcs.py +5 -2
  7. api_logic_server_cli/prototypes/base/api/api_discovery/mcp_discovery.py +63 -24
  8. api_logic_server_cli/prototypes/base/config/logging.yml +5 -0
  9. api_logic_server_cli/prototypes/base/config/server_setup.py +73 -0
  10. api_logic_server_cli/prototypes/base/integration/mcp/examples/mcp_discovery_response.json +150 -0
  11. api_logic_server_cli/prototypes/base/integration/mcp/examples/mcp_request.prompt +46 -0
  12. api_logic_server_cli/prototypes/base/integration/mcp/examples/mcp_tool_context_response.json +34 -0
  13. api_logic_server_cli/prototypes/base/integration/mcp/examples/mcp_tool_context_response_get.json +18 -0
  14. api_logic_server_cli/prototypes/base/integration/mcp/mcp_client_executor.py +129 -275
  15. api_logic_server_cli/prototypes/basic_demo/customizations/logic/logic_discovery/email_request.py +2 -0
  16. api_logic_server_cli/prototypes/basic_demo/customizations/logic/logic_discovery/mcp_client_executor_request.py +15 -288
  17. api_logic_server_cli/prototypes/basic_demo/customizations/ui/admin/admin.yaml +3 -3
  18. api_logic_server_cli/prototypes/basic_demo/customizations/ui/admin/home.js +48 -0
  19. api_logic_server_cli/prototypes/manager/{REAMDE.md → README.md} +30 -2
  20. api_logic_server_cli/prototypes/manager/system/genai/mcp_learning/mcp.prompt +12 -0
  21. {apilogicserver-14.5.17.dist-info → apilogicserver-15.0.9.dist-info}/METADATA +3 -3
  22. {apilogicserver-14.5.17.dist-info → apilogicserver-15.0.9.dist-info}/RECORD +27 -34
  23. api_logic_server_cli/prototypes/base/integration/mcp/README_mcp.md +0 -15
  24. api_logic_server_cli/prototypes/base/integration/mcp/test_notes.txt +0 -37
  25. api_logic_server_cli/prototypes/basic_demo/customizations/api/api_discovery/mcp_discovery.py +0 -96
  26. api_logic_server_cli/prototypes/basic_demo/customizations/config/server_setup.py +0 -388
  27. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/.DS_Store +0 -0
  28. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/README_mcp.md +0 -15
  29. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/Zmcp_client_executor.py +0 -294
  30. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_schema.txt +0 -47
  31. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_server_discovery.json +0 -9
  32. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_tool_context.json +0 -25
  33. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/test_notes.txt +0 -37
  34. api_logic_server_cli/prototypes/manager/READMEz.md +0 -667
  35. /api_logic_server_cli/prototypes/base/integration/mcp/{mcp_schema.txt → examples/mcp_schema.txt} +0 -0
  36. {apilogicserver-14.5.17.dist-info → apilogicserver-15.0.9.dist-info}/WHEEL +0 -0
  37. {apilogicserver-14.5.17.dist-info → apilogicserver-15.0.9.dist-info}/entry_points.txt +0 -0
  38. {apilogicserver-14.5.17.dist-info → apilogicserver-15.0.9.dist-info}/licenses/LICENSE +0 -0
  39. {apilogicserver-14.5.17.dist-info → apilogicserver-15.0.9.dist-info}/top_level.txt +0 -0
@@ -1,279 +1,17 @@
1
1
  """
2
- This simulates the MCP Client Executor,
3
- which takes a natural language query and converts it into a tool context block:
4
-
5
- 1. Discovers MCP servers (from config)
6
- 2. Queries OpenAI's GPT-4 model to obtain the tool context based on a provided schema and a natural language query
7
- 3. Processes the tool context (calls the indicated MCP (als) endpoints)
8
-
9
- Notes:
10
- * See: integration/mcp/README_mcp.md
11
- * python api_logic_server_run.py
12
-
2
+ Invokes MCP client executor to process MCP requests when a new SysMcp row is inserted.
13
3
  """
14
4
 
15
5
  import json
16
- import os, sys
6
+ import os, logging
17
7
  from typing import Dict, List
18
8
  import openai
19
9
  import requests
20
- from logic_bank.exec_row_logic.logic_row import LogicRow
21
10
  from logic_bank.logic_bank import Rule
11
+ from logic_bank.exec_row_logic.logic_row import LogicRow
22
12
  from database import models
23
13
  from logic_bank.util import ConstraintException
24
-
25
- # Set your OpenAI API key
26
- openai.api_key = os.getenv("APILOGICSERVER_CHATGPT_APIKEY")
27
-
28
- server_url = os.getenv("APILOGICSERVER_URL", "http://localhost:5656/api")
29
-
30
- # debug settings
31
- test_type = 'orchestration' # 'simple_get' or 'orchestration'
32
- create_tool_context_from_llm = True
33
- ''' set to False to bypass LLM call and save 2-3 secs in testing '''
34
- use_test_schema = False
35
- ''' True means bypass discovery, use hard-coded schedma file '''
36
-
37
- def discover_mcp_servers():
38
- """ Discover the MCP servers by calling the /api/.well-known/mcp.json endpoint.
39
- This function retrieves the list of available MCP servers and their capabilities.
40
- """
41
- global server_url, use_test_schema
42
-
43
- # create schema_text (for prompt), by reading integration/mcp/mcp_schema.txt
44
-
45
- # find the servers - read the mcp_server_discovery.json file
46
- discovery_file_path = os.path.join(os.path.dirname(__file__), "../../integration/mcp/mcp_server_discovery.json")
47
- try:
48
- with open(discovery_file_path, "r") as discovery_file:
49
- discovery_data = json.load(discovery_file)
50
- print(f"\n1. Discovered MCP servers from config file: {discovery_file_path}:" + json.dumps(discovery_data, indent=4))
51
- except FileNotFoundError:
52
- print(f"Discovery file not found at {discovery_file_path}.")
53
- except json.JSONDecodeError as e:
54
- print(f"Error decoding JSON from {discovery_file_path}: {e}")
55
-
56
- for each_server in discovery_data["servers"]:
57
- discovery_url = each_server["schema_url"]
58
-
59
- # Call the discovery_url to get the MCP/API schema
60
- try:
61
- response = requests.get(discovery_url)
62
- if response.status_code == 200:
63
- api_schema = response.json()
64
- print()
65
- request_print = json.dumps(api_schema, indent=4)[0:400] + '\n... etc' # limit for readability
66
- print(f"\n\nAPI Schema from discovery schema_url: {discovery_url}:\n" + request_print)
67
- else:
68
- print(f"Failed to retrieve API schema from {discovery_url}: {response.status_code}")
69
- except requests.RequestException as e:
70
- print(f"Error calling OpenAPI URL: {e}")
71
- return json.dumps(api_schema)
72
-
73
-
74
- def get_user_nl_query_and_training(query: str):
75
- """ Get the natural language query from the user.
76
- Add training for the LLM to generate a tool context block.
77
-
78
- """
79
-
80
- global test_type
81
- # read file docs/mcp_learning/mcp.prompt
82
- prompt_file_path = os.path.join(os.path.dirname(__file__), "../../docs/mcp_learning/mcp.prompt")
83
- if os.path.exists(prompt_file_path):
84
- with open(prompt_file_path, "r") as prompt_file:
85
- training_prompt = prompt_file.read()
86
- # print(f"\nLoaded training prompt from {prompt_file_path}:\n{training_prompt}")
87
- else:
88
- training_prompt = ""
89
- print(f"Prompt file not found at {prompt_file_path}.")
90
- return query + "\n\n" + training_prompt
91
-
92
-
93
- def query_llm_with_nl(schema_text, nl_query):
94
- """
95
- Query the LLM with a natural language query and schema text to generate a tool context block.
96
-
97
- It handles both orchestration and simple GET requests.
98
- """
99
-
100
- global test_type, create_tool_context_from_llm
101
-
102
- content = f"Natural language query:\n {nl_query}\nSchema:\n{schema_text}"
103
- messages = [
104
- {
105
- "role": "system",
106
- "content": "You are an API planner that converts natural language queries into MCP Tool Context blocks using JSON:API. Return only the tool context as JSON."
107
- },
108
- {
109
- "role": "user",
110
- "content": f"{content}"
111
- }
112
- ]
113
-
114
- request_print = content[0:1200] + '\n... etc' # limit for readability
115
- print("\n\n2a. LLM request:\n", request_print)
116
- # print("\n2b. NL Query:\n", nl_query)
117
- # print("\n2c. schema_text: (truncated) \n")
118
- # schema_print = json.dumps(json.loads(schema_text), indent=4)[:400] # limit for readability
119
- # print(schema_print)
120
-
121
- if create_tool_context_from_llm: # takes 2-3 seconds...
122
- response = openai.chat.completions.create(
123
- model="gpt-4",
124
- messages=messages,
125
- temperature=0.2
126
- )
127
-
128
- tool_context_str = response.choices[0].message.content
129
- tool_context_str_no_cr = tool_context_str.replace("\n", '') # convert single quotes to double quotes
130
- try:
131
- tool_context = json.loads(tool_context_str_no_cr)
132
- except json.JSONDecodeError:
133
- print("Failed to decode JSON from response:", tool_context_str)
134
- return None
135
-
136
- print("\n2d. generated tool context from LLM:\n", json.dumps(tool_context, indent=4))
137
-
138
- if "resources" not in tool_context:
139
- raise ConstraintException("GenAI Error - LLM response does not contain 'resources'.")
140
- return tool_context
141
-
142
-
143
- def process_tool_context(tool_context):
144
- """ Process the orchestration request by executing multiple tool context blocks.
145
- This executes the tool context blocks against a live JSON:API server.
146
- It handles both GET and POST requests, and it can
147
- orchestrate multiple requests based on the provided tool context.
148
-
149
- Note the orchestration is processed by the client executor (here), not the server executor.
150
-
151
- Research:
152
-
153
- 1. How is this a "USB", since the request was specific about JSON:API?
154
- 2. How is it clear to loop through the tool_context[0] and call tool_context[1]?
155
- """
156
- global server_url
157
-
158
- def get_query_param_filter(query_params):
159
- """ return json:api filter
160
-
161
- eg
162
- curl -qg 'http://localhost:5656/api/Order?filter=[{"name":"date_shipped","op":"eq","val":null},{"name":"CreatedOn","op":"lt","val":"2023-07-14"}]'
163
-
164
- curl -qg 'http://localhost:5656/api/Order?filter=[{"name":"date_shipped","op":"gt","val":"2023-07-14"}]'
165
- curl -qg 'http://localhost:5656/api/Order?filter=[{"name":"date_shipped","op":"eq","val":null}]'
166
- curl -qg 'http://localhost:5656/api/Customer?filter=[{"name":"credit_limit","op":"gt","val":"1000"}]'
167
-
168
- query_params might be simple:
169
- "query_params": [ {"name": "credit_limit", "op": "gt", "val": "1000"} ]
170
- ==> ?filter=[{"name":"credit_limit","op":"gt","val":"1000"}]
171
-
172
- or a list:
173
- "query_params": [
174
- {
175
- "name": "date_shipped",
176
- "op": "eq",
177
- "val": None
178
- },
179
- {
180
- "name": "date_created",
181
- "op": "lt",
182
- "val": "2023-07-14"
183
- }
184
- ],
185
-
186
- """
187
-
188
- added_rows = 0
189
-
190
- query_param_filter = ''
191
- assert isinstance(query_params, list), "Query Params filter expected to be a list"
192
- query_param_filter = 'filter=' + str(query_params)
193
- # use urlencode to convert to JSON:API format...
194
- # val urllib.parse.quote() or urllib.parse.urlencode()
195
- # tool instructions... filtering, email etc "null"
196
- query_param_filter = query_param_filter.replace("'", '"') # convert single quotes to double quotes
197
- query_param_filter = query_param_filter.replace("None", 'null')
198
- query_param_filter = query_param_filter.replace('"null"', 'null')
199
- # query_param_filter = query_param_filter.replace("date_created", 'CreatedOn') # TODO - why this name?
200
- return query_param_filter # end get_query_param_filter
201
-
202
- def move_fields(src: dict, dest: dict, context_data: dict):
203
- """ Move fields from src to dest, replacing any variables with their values from context_data."""
204
- for variable_name, value in src.items():
205
- move_value = value
206
- if move_value.startswith("{") and move_value.endswith("}"):
207
- # strip the braces, and get the name after the first dot, # eg: "{Order.customer_id}" ==> "customer_id"``
208
- move_name = move_value[1:-1] # strip the braces
209
- if '.' in move_value:
210
- move_name = move_name.split('.', 1)[1]
211
- move_value = context_data['attributes'][move_name]
212
- dest[variable_name] = move_value
213
- return dest
214
-
215
- def print_get_response(query_param_filter, mcp_response):
216
- """ Print the response from the GET request. """
217
- print("\n3. MCP Server (als) GET filter(query_param_filter):\n", query_param_filter)
218
- print(" GET Response:\n", mcp_response.text)
219
- results : List[Dict] = mcp_response.json()['data']
220
- # print results in a table format
221
- if results:
222
- # Get all unique keys from all result dicts
223
- keys = set()
224
- for row in results:
225
- if isinstance(row, dict):
226
- keys.update(row.keys())
227
- keys = list(keys)
228
- # Print header
229
- print("\n| " + " | ".join(keys) + " |")
230
- print("|" + "|".join(["---"] * len(keys)) + "|")
231
- # Print rows
232
- for row in results:
233
- print("| " + " | ".join(str(row.get(k, "")) for k in keys) + " |")
234
- else:
235
- print("No results found.")
236
-
237
- assert isinstance(tool_context, (dict, list)), "Tool context expected to be a dictionary"
238
- context_data = {}
239
- added_rows = 0
240
-
241
- for each_block in tool_context["resources"]:
242
- if process_tool_context := True:
243
- if each_block["method"] == "GET":
244
- query_param_filter = get_query_param_filter(each_block["query_params"])
245
- headers = {"Content-Type": "application/vnd.api+json"}
246
- if "headers" in each_block:
247
- headers.update(each_block["headers"])
248
- mcp_response = requests.get(
249
- url = each_block["base_url"] + each_block["path"],
250
- headers=headers,
251
- params=query_param_filter
252
- )
253
- context_data = mcp_response.json()['data'] # result rows...
254
- print_get_response(query_param_filter, mcp_response)
255
- elif each_block["method"] in ["POST"]:
256
- for each_order in context_data:
257
- url = each_block["base_url"] + each_block["path"]
258
- json_update_data = { 'data': {"type": each_block["path"][1:], 'attributes': {} } }
259
- json_update_data_attributes = json_update_data["data"]["attributes"]
260
- move_fields( src= each_block["body"], dest=json_update_data_attributes, context_data=each_order)
261
- # eg: POST http://localhost:5656/api/SysEmail {'data': {'type': 'SysEmail', 'attributes': {'customer_id': 5, 'message': {'to': '{{ order.customer_id }}', 'subject': 'Discount for your order', 'body': 'Dear customer, you have a discount for your recent order. Thank you for shopping with us.'}}}}
262
- headers = {"Content-Type": "application/vnd.api+json"}
263
- if "headers" in each_block:
264
- headers.update(each_block["headers"])
265
- mcp_response = requests.post(
266
- url=url,
267
- headers=headers,
268
- json=json_update_data
269
- )
270
- added_rows += 1
271
- pass
272
- print("\n3. MCP Server (als) POST Response:\n", mcp_response.text)
273
- if added_rows > 0:
274
- print(f"...Added {added_rows} rows to the database; last row (only) shown above.")
275
- return mcp_response
276
-
14
+ import integration.mcp.mcp_client_executor as mcp_client_executor
277
15
 
278
16
 
279
17
  def declare_logic():
@@ -281,40 +19,29 @@ def declare_logic():
281
19
  This illustrates the request pattern.
282
20
 
283
21
  The request pattern is a common pattern in API Logic Server,
284
- where an insert triggers service invocation, such as sending email.
22
+ where an insert triggers service invocation, such as sending email or issue mcp requests.
285
23
 
286
- The Email table includes the columns for the email (e,g, recipient, subject, message).
287
-
288
- Using a request object enables you to wrap the service call with logic, eg:
289
-
290
- * *email requirement: do not send mail if customer has opted out*
24
+ The SysMCP table captures the prompt (in the row); this logic executes the MCP processing.
291
25
 
292
26
  See: https://apilogicserver.github.io/Docs/Integration-MCP/#3a-logic-request-pattern
293
27
  """
294
28
 
295
29
 
296
- def mcp_client_executor(row: models.SysMcp, old_row: models.SysMcp, logic_row: LogicRow):
30
+ def mcp_client_executor_event(row: models.SysMcp, old_row: models.SysMcp, logic_row: LogicRow):
297
31
  """
298
32
 
299
- #als: create an MCP request
33
+ #als: create an MCP request. See https://apilogicserver.github.io/Docs/Integration-MCP/
300
34
 
301
- curl -X 'POST' 'http://localhost:5656/api/SysMcp/' -H 'accept: application/vnd.api+json' -H 'Content-Type: application/json' -d '{ "data": { "attributes": {"request": "List the orders date_shipped is null and CreatedOn before 2023-07-14, and send a discount email (subject: '\''Discount Offer'\'') to the customer for each one."}, "type": "SysMcp"}}'
35
+ Test:
36
+ * curl -X 'POST' 'http://localhost:5656/api/SysMcp/' -H 'accept: application/vnd.api+json' -H 'Content-Type: application/json' -d '{ "data": { "attributes": {"request": "List the orders date_shipped is null and CreatedOn before 2023-07-14, and send a discount email (subject: '\''Discount Offer'\'') to the customer for each one."}, "type": "SysMcp"}}'
37
+ * Or, use the Admin App and insert a row into SysMCP, eg:
38
+ * List the orders date_shipped is null and CreatedOn before 2023-07-14, and send a discount email (subject: 'Discount Offer') to the customer for each one."
302
39
 
303
40
  Args:
304
- row (Mcp): inserted MCP with prompt
41
+ row (Mcp): inserted SysMcp with prompt
305
42
  old_row (Mcp): n/a
306
43
  logic_row (LogicRow): bundles curr/old row, with ins/upd/dlt logic
307
44
  """
308
- schema_text = discover_mcp_servers() # see: 1-discovery-from-als
309
-
310
- query_example = "List the orders date_shipped is null and CreatedOn before 2023-07-14, and send a discount email (subject: 'Discount Offer') to the customer for each one."
311
- query = row.request
312
- prompt = get_user_nl_query_and_training(query)
313
-
314
- tool_context = query_llm_with_nl(schema_text, prompt) # see: 2-tool-context-from-LLM
315
-
316
- mcp_response = process_tool_context(tool_context) # see: 3-MCP-server response
317
-
318
- print("\nTest complete.\n")
45
+ result = mcp_client_executor.mcp_client_executor(row.request)
319
46
 
320
- Rule.row_event(on_class=models.SysMcp, calling=mcp_client_executor) # see above
47
+ Rule.row_event(on_class=models.SysMcp, calling=mcp_client_executor_event) # see above
@@ -131,13 +131,13 @@ resources:
131
131
  user_key: id
132
132
  SysMcp:
133
133
  attributes:
134
+ - name: request
135
+ type: textarea
134
136
  - label: ' id*'
135
137
  name: id
136
138
  search: true
137
139
  sort: true
138
- - name: request
139
- - name: request_prompt
140
- - name: completion
140
+ show_when: isInserting == false
141
141
  type: SysMcp
142
142
  user_key: id
143
143
  settings:
@@ -0,0 +1,48 @@
1
+ const sla_doc =
2
+ '<div class="MuiTypography-root jss4" style="color: rgba(0, 0, 0, 0.66)">' +
3
+ '<div style="text-align:center">' +
4
+ '<h2>Welcome to API Logic Server</h2>' +
5
+ '</div><br>' +
6
+ '<h3><a class="custom" style="color: #3f51b5;" rel="nofollow" href="https://apilogicserver.github.io/Docs/" target="_blank">API Logic Server</a> ' +
7
+ 'creates <i>customizable</i> model-driven systems, instantly from your ' +
8
+ 'database:' +
9
+ '</h3>' +
10
+ '<h4>1. Automatic Admin App</h4>' +
11
+ '<ul>' +
12
+ ' <li>For instant collaboration and Back Office data maintenance</li>' +
13
+ ' <li>Rich functionality: multi-page, multi-table</li>' +
14
+ ' <li>Explore this Admin App, ' +
15
+ ' and how to <a class="custom" style="color: #3f51b5" rel="nofollow" href="https://apilogicserver.github.io/Docs/Admin-Customization/" target="_blank">customize it</a></li>' +
16
+ '</ul>' +
17
+ '<h4>2. API, with <a class="custom" style="color: #3f51b5;" rel="nofollow" href="/api" target="_blank">oas/Swagger</a></h4>' +
18
+ '<ul>' +
19
+ ' <li>For custom app dev, integration</li>' +
20
+ ' <li>Rich functionality: endpoint for each table, with filtering, pagination, related data</li>' +
21
+ ' <li><a class="custom" style="color: #3f51b5" rel="nofollow" href="https://apilogicserver.github.io/Docs/API-Customize/" target="_blank">Customizable</a>: add your own endpoints</li>' +
22
+ ' <li><a class="custom" style="color: #3f51b5" rel="nofollow" href="http://localhost:5656/stop" target="_blank">Stop</a> the server</li>' +
23
+ '</ul>' +
24
+ '<h4>3. Business Logic, for <span class="JoinedField" title="Often nearly half the app -- automation required"><span>backend processing</span> </span></h4>' +
25
+ '<ul>' +
26
+ ' <li>Spreadsheet-like rules for multi-table derivations and constraints</li>' +
27
+ ' <li>Extensible with Python events for email, messages, etc</li>' +
28
+ ' <li><a class="custom" style="color: #3f51b5" rel="nofollow" href="https://apilogicserver.github.io/Docs/Logic-Why/" target="_blank">Explore</a> ' +
29
+ ' how logic can meaningfully improve ' +
30
+ ' <a class="custom" style="color: #3f51b5" rel="nofollow" href="https://github.com/valhuber/LogicBank/wiki/by-code" title="Rules are 40X more concise than code, and address over 95% of database logic" target="_blank">conciseness</a> ' +
31
+ ' and quality</li>' +
32
+ '</ul>' +
33
+ '<h4>4. MCP-enabled, to <span class="JoinedField" title="Often nearly half the app -- automation required"><span>Enable Bus Users to use Natural Language to create multi-step execution flows</span> </span></h4>'+
34
+ '<ul>' +
35
+ ' <li>For more information, <a class="custom" style="color: #3f51b5" rel="nofollow" href="https://apilogicserver.github.io/Docs/Integration-MCP/" target="_blank">Click here</a></li>' +
36
+ ' <li>Create a new SysMcp, and enter: List the orders date_shipped is null and CreatedOn before 2023-07-14, and send a discount email (subject: \'Discount Offer\') to the customer for each one.</li>' +
37
+ '</ul>' +
38
+ '</div>'
39
+
40
+
41
+ function getContent(){
42
+
43
+ let result = '<button class="MuiButtonBase-root MuiButton-root MuiButton-text makeStyles-widget-159 MuiButton-textPrimary" tabindex="0" type="button" ><span class="MuiButton-label">Loaded External Component. </span></button>';
44
+ result = ""
45
+ result += sla_doc;
46
+ return result;
47
+ }
48
+
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: Welcome
3
3
  Description: Instant mcp-enabled microservices, standard projects, declarative business logic
4
- version info: 2.0 (05/24/2025)
4
+ version info: 2.0 (05/24/2025) from install
5
5
  ---
6
6
  <style>
7
7
  .md-typeset h1,
@@ -250,7 +250,9 @@ Observe the rules firing in the console log - see Logic In Action, below.
250
250
 
251
251
  <summary>See Logic In Action </summary>
252
252
 
253
- <br>
253
+ <br>[Declare logic](Logic.md#declaring-rules){:target="_blank" rel="noopener"} with WebGenAI, or in your IDE using code completion or Natural Language:
254
+
255
+ ![Nat Lang Logic](images/sample-ai/copilot/copilot-logic-chat.png)
254
256
 
255
257
  **a. Chaining**
256
258
 
@@ -263,6 +265,9 @@ Note that it's a `Multi-Table Transaction`, as indicated by the indentation. Th
263
265
  **b. 40X More Concise**
264
266
 
265
267
  The 5 spreadsheet-like rules represent the same logic as 200 lines of code, [shown here](https://github.com/valhuber/LogicBank/wiki/by-code). That's a remarkable 40X decrease in the backend half of the system.
268
+
269
+ > 💡 No FrankenCode<br>Note the rules look like syntactically correct requirements. They are not turned into piles of unmanageable "frankencode" - see [models not frankencode](https://www.genai-logic.com/faqs#h.3fe4qv21qtbs){:target="_blank" rel="noopener"}.
270
+
266
271
  <br><br>
267
272
 
268
273
  **c. Automatic Re-use**
@@ -285,6 +290,29 @@ Optionally, you can use the Behave TDD approach to define tests, and the Rules R
285
290
 
286
291
  &nbsp;
287
292
 
293
+ ### Logic-Enabled MCP
294
+
295
+ Logic is automatically executed in your MCP-enabled API. For example, consider the following MCP orchestration:
296
+
297
+ ```
298
+ List the orders date_shipped is null and CreatedOn before 2023-07-14,
299
+ and send a discount email (subject: 'Discount Offer') to the customer for each one.
300
+ ```
301
+
302
+ When sending email, we require a business rules to ensure it respects the opt-out policy:
303
+
304
+ ![email request](images/integration/mcp/3a-email-logic.png)
305
+
306
+ With the server running, test it by posting to `SysMCP` like this:
307
+
308
+ ```bash
309
+ curl -X 'POST' 'http://localhost:5656/api/SysMcp/' -H 'accept: application/vnd.api+json' -H 'Content-Type: application/json' -d '{ "data": { "attributes": {"request": "List the orders date_shipped is null and CreatedOn before 2023-07-14, and send a discount email (subject: '\''Discount Offer'\'') to the customer for each one."}, "type": "SysMcp"}}'
310
+ ```
311
+
312
+ For more on MCP, [click here](Integration-MCP.md){:target="_blank" rel="noopener"}.
313
+
314
+ &nbsp;
315
+
288
316
  ## 4. Iterate with Rules and Python
289
317
 
290
318
  Not only are spreadsheet-like rules 40X more concise, they meaningfully simplify maintenance. Let's take an example:
@@ -1,3 +1,15 @@
1
+ To issue one request per row from a prior step (fan-out), use the syntax:
2
+
3
+ "$<stepIndex>[*].<fieldName>"
4
+
5
+ For example, if step 0 returns orders, and you want to send a POST per customer:
6
+
7
+ Before (incorrect):
8
+ "customer_id": "{customer_id}"
9
+
10
+ After (correct):
11
+ "customer_id": "$0[*].customer_id"
12
+
1
13
  Only if 'email' is in the Natural language query, send email by issing a POST request to the SysEmail endpoint, setting the subject, message and customer_id in the body. DO NOT include a POST unless the word ‘email’ appears in the user query.
2
14
 
3
15
  Format response as mcp_responseFormat.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ApiLogicServer
3
- Version: 14.5.17
3
+ Version: 15.0.9
4
4
  Author-email: Val Huber <apilogicserver@gmail.com>
5
5
  License: BSD-3-Clause
6
6
  Project-URL: Homepage, https://www.genai-logic.com
@@ -84,7 +84,7 @@ Dynamic: license-file
84
84
 
85
85
  # TL;DR
86
86
 
87
- Create an executable project (API and Admin App) from a database or natural language prompt with 1 command, customize with declarative rules and Python in your IDE, containerize and deploy.
87
+ Create an executable project (MCP-enabled API and Admin App) from a database or natural language prompt with 1 command; customize with declarative rules and Python in your IDE, containerize and deploy.
88
88
 
89
89
  &nbsp;
90
90
 
@@ -136,7 +136,7 @@ For Developers and their organizations seeking to **increase business agility,**
136
136
 
137
137
  API Logic Server provides ***Microservice Automation:*** create executable projects with 1 command:
138
138
 
139
- 1. ***API Automation:*** crud for each table, with pagination, optimistic locking, filtering and sorting, and
139
+ 1. ***MCP-enabled API Automation:*** crud for each table, with pagination, optimistic locking, filtering and sorting, and
140
140
 
141
141
  2. ***App Automation:*** a multi-page, multi-table Admin App. <br>
142
142