diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6b690ff --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.11.11-slim + +RUN pip install uv + +WORKDIR /app + +COPY . /app + +ENV FLOWS='[ \ + { \ + "flow_id": "id1", \ + "name": "flow1", \ + "description": "desc1", \ + "api_key": "key1:secret1" \ + } \ +]' + +CMD ["uv", "run", "python", "./src/mcp_server/server.py"] diff --git a/README.md b/README.md index 0747e06..3e80b50 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,20 @@ Before using the mcp server, you should prepare a config.yaml to save your workf api_key: 'API Key:API Secret' # required ``` +### Set workflow info in Environment Variable +You can also choose to set workflow info in environment variables. For example, configure environment variables in Dockerfile: +```Dokerfile +ENV FLOWS='[ \ + { \ + "flow_id": "id1", \ + "name": "flow1", \ + "description": "desc1", \ + "api_key": "key1:secret1" \ + } \ +]' +``` + + #### Get workflow authentication information 1. [Create a bot](https://xinghuo.xfyun.cn/botcenter/createbot) ![](./images/create_workflow.png) diff --git a/glama.json b/glama.json new file mode 100644 index 0000000..597aeab --- /dev/null +++ b/glama.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://glama.ai/mcp/schemas/server.json", + "maintainers": [ + "iflytek" + ] +} \ No newline at end of file diff --git a/src/mcp_server/entities/ifly_client.py b/src/mcp_server/entities/ifly_client.py index 659bcfc..0a1f03c 100644 --- a/src/mcp_server/entities/ifly_client.py +++ b/src/mcp_server/entities/ifly_client.py @@ -21,16 +21,22 @@ class SysTool(Enum): class IFlyWorkflowClient(ABC): base_url = "https://xingchen-api.xf-yun.com" - def __init__(self, config_path: str = os.getenv("CONFIG_PATH")): + def __init__(self, config_path: str = os.getenv("CONFIG_PATH"), env_config: str = os.getenv("FLOWS")): """ init :param config_path: config path,default is CONFIG_PATH """ - if not config_path: - raise ValueError("CONFIG_PATH is not set") - - with open(config_path, 'r', encoding='utf-8') as file: - self.flows = [Flow(**flow) for flow in yaml.safe_load(file)] + self.flows = [] + if config_path: + with open(config_path, 'r', encoding='utf-8') as file: + for flow in yaml.safe_load(file): + self.flows.append(Flow(**flow)) + if env_config: + flows = json.loads(env_config) + for flow in flows: + self.flows.append(Flow(**flow)) + if len(self.flows) == 0: + raise Exception("Unable to find config in CONFIG_PATH or environment variables.") self.name_idx: Dict[str, int] = {} # get flow info