libentry 1.28.4__py3-none-any.whl → 1.28.6__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.
libentry/mcp/api.py CHANGED
@@ -94,7 +94,7 @@ def api(
94
94
  api_info = APIInfo(
95
95
  path=_path,
96
96
  methods=methods,
97
- name=name or fn_name,
97
+ name=name or _path.lstrip("/"),
98
98
  description=description or fn_doc,
99
99
  tag=tag
100
100
  )
libentry/mcp/service.py CHANGED
@@ -812,8 +812,11 @@ class Route:
812
812
 
813
813
  class FlaskServer(Flask):
814
814
 
815
- def __init__(self, service):
815
+ def __init__(self, service, options: Dict[str, Any]):
816
816
  super().__init__(__name__)
817
+ self.options = options
818
+ self.access_control_allow_origin = self.options.get("access_control_allow_origin")
819
+ self.access_control_allow_methods = self.options.get("access_control_allow_methods")
817
820
 
818
821
  self.service_routes = {}
819
822
  self.builtin_routes = {}
@@ -876,10 +879,20 @@ class FlaskServer(Flask):
876
879
  return routes
877
880
 
878
881
  def ok(self, body: Union[str, Iterable[str], None], mimetype: str):
879
- return self.response_class(body, status=200, mimetype=mimetype)
882
+ response = self.response_class(body, status=200, mimetype=mimetype)
883
+ if self.access_control_allow_origin:
884
+ response.headers["Access-Control-Allow-Origin"] = "*"
885
+ if self.access_control_allow_methods:
886
+ response.headers["Access-Control-Allow-Methods"] = "GET, POST"
887
+ return response
880
888
 
881
889
  def error(self, body: str, mimetype=MIME.plain.value):
882
- return self.response_class(body, status=500, mimetype=mimetype)
890
+ response = self.response_class(body, status=500, mimetype=mimetype)
891
+ if self.access_control_allow_origin:
892
+ response.headers["Access-Control-Allow-Origin"] = "*"
893
+ if self.access_control_allow_methods:
894
+ response.headers["Access-Control-Allow-Methods"] = "GET, POST"
895
+ return response
883
896
 
884
897
  @api.get("/")
885
898
  def index(self, name: str = None):
@@ -937,7 +950,7 @@ class GunicornApplication(BaseApplication):
937
950
  service = self._create_service(self.service_type, self.service_config)
938
951
  logger.info("Service initialized.")
939
952
 
940
- return FlaskServer(service)
953
+ return FlaskServer(service, self.options)
941
954
 
942
955
  @staticmethod
943
956
  def _create_service(service_type, service_config):
@@ -1014,6 +1027,16 @@ class RunServiceConfig(BaseModel):
1014
1027
  description="SSL certificate file.",
1015
1028
  default=None
1016
1029
  )
1030
+ access_control_allow_origin: Optional[str] = Field(
1031
+ title="Access control allow origin",
1032
+ description="Access control allow origin.",
1033
+ default="*"
1034
+ )
1035
+ access_control_allow_methods: Optional[str] = Field(
1036
+ title="Access control allow methods",
1037
+ description="Access control allow methods.",
1038
+ default="GET, POST"
1039
+ )
1017
1040
 
1018
1041
 
1019
1042
  def run_service(
@@ -1086,7 +1109,9 @@ def run_service(
1086
1109
  "keyfile": run_config.keyfile,
1087
1110
  "certfile": run_config.certfile,
1088
1111
  "worker_class": run_config.worker_class,
1089
- "ssl_context": ssl_context
1112
+ "ssl_context": ssl_context,
1113
+ "access_control_allow_origin": run_config.access_control_allow_origin,
1114
+ "access_control_allow_methods": run_config.access_control_allow_methods,
1090
1115
  }
1091
1116
  for name, value in options.items():
1092
1117
  logger.info(f"Option {name}: {value}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: libentry
3
- Version: 1.28.4
3
+ Version: 1.28.6
4
4
  Summary: Entries for experimental utilities.
5
5
  Home-page: https://github.com/XoriieInpottn/libentry
6
6
  Author: xi
@@ -11,9 +11,9 @@ libentry/schema.py,sha256=T_hM_F25ntfvczFFpJUM7_fu9V3J3-qR9kZR8bcxqhQ,10439
11
11
  libentry/test_api.py,sha256=bs7P8gveLtuUvHxrpujSrfuYqLVJ3fOXVg_MZnZxoJ4,4504
12
12
  libentry/utils.py,sha256=vCm6UyAlibnPOlPJHZO57u3TXhw5PZmGM5_vBAPUnB4,1981
13
13
  libentry/mcp/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
14
- libentry/mcp/api.py,sha256=GDErVCz_hh_ZeMxLS8bTPyBUhCTHw3Mm-nGFMV2W2yo,3669
14
+ libentry/mcp/api.py,sha256=hhveOjDYhWiEEq3C7wSAOdpbPn9JP1T1CW3QYWrLHa4,3679
15
15
  libentry/mcp/client.py,sha256=_O-O6OETwHidhiFmg7P01NIrVhHgEetwFeFfJNqRt6M,24899
16
- libentry/mcp/service.py,sha256=Zl031pZS-4wJjp0YG6825iDgcKNev8RdOANkWwO7WkU,40272
16
+ libentry/mcp/service.py,sha256=rTf_hYzOC2-1js8ly_6A6kPkzQyUVrHNMnspGqxmAfo,41576
17
17
  libentry/mcp/types.py,sha256=aAoVO4jjqEvDzNneuZapmRYonLLnGsbcLoypVyRNNYg,12389
18
18
  libentry/service/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
19
19
  libentry/service/common.py,sha256=OVaW2afgKA6YqstJmtnprBCqQEUZEWotZ6tHavmJJeU,42
@@ -22,10 +22,10 @@ libentry/service/list.py,sha256=ElHWhTgShGOhaxMUEwVbMXos0NQKjHsODboiQ-3AMwE,1397
22
22
  libentry/service/running.py,sha256=FrPJoJX6wYxcHIysoatAxhW3LajCCm0Gx6l7__6sULQ,5105
23
23
  libentry/service/start.py,sha256=mZT7b9rVULvzy9GTZwxWnciCHgv9dbGN2JbxM60OMn4,1270
24
24
  libentry/service/stop.py,sha256=wOpwZgrEJ7QirntfvibGq-XsTC6b3ELhzRW2zezh-0s,1187
25
- libentry-1.28.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
26
- libentry-1.28.4.dist-info/METADATA,sha256=AimMU3YMw_WgXPhnQTe-hp65BqId_vTWx1I6rtkLDHU,1135
27
- libentry-1.28.4.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
28
- libentry-1.28.4.dist-info/entry_points.txt,sha256=1v_nLVDsjvVJp9SWhl4ef2zZrsLTBtFWgrYFgqvQBgc,61
29
- libentry-1.28.4.dist-info/top_level.txt,sha256=u2uF6-X5fn2Erf9PYXOg_6tntPqTpyT-yzUZrltEd6I,9
30
- libentry-1.28.4.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
31
- libentry-1.28.4.dist-info/RECORD,,
25
+ libentry-1.28.6.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
26
+ libentry-1.28.6.dist-info/METADATA,sha256=UiHq2k_zQbiZuXDqyPAIoP4MqxDxBRLEjB7-h8woupE,1135
27
+ libentry-1.28.6.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
28
+ libentry-1.28.6.dist-info/entry_points.txt,sha256=1v_nLVDsjvVJp9SWhl4ef2zZrsLTBtFWgrYFgqvQBgc,61
29
+ libentry-1.28.6.dist-info/top_level.txt,sha256=u2uF6-X5fn2Erf9PYXOg_6tntPqTpyT-yzUZrltEd6I,9
30
+ libentry-1.28.6.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
31
+ libentry-1.28.6.dist-info/RECORD,,