Skip to content

config: add glama.json #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions glama.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://glama.ai/mcp/schemas/server.json",
"maintainers": [
"iflytek"
]
}
18 changes: 12 additions & 6 deletions src/mcp_server/entities/ifly_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down