main.py•7.81 kB
# generated by fastapi-codegen:
# filename: openapi.yaml
# timestamp: 2025-06-29T08:30:02+00:00
import argparse
import json
import os
from datetime import date as date_aliased
from typing import *
from typing import Optional, Union
from autogen.mcp.mcp_proxy import MCPProxy
from autogen.mcp.mcp_proxy.security import APIKeyHeader, BaseSecurity
from pydantic import conint
from starlette.requests import Request
from models import (
AbsencePeriodResponse,
AbsencePeriodsResponse,
AttendancePeriodsResponse,
CompanyEmployeesPostResponse,
CompanyTimeOffsPostResponse,
CompanyTimeOffTypesGetResponse,
CreateTimeOffPeriodRequest,
DetailedErrorResponse,
EmployeeResponse,
Employees,
EmployeesResponse,
ErrorResponse,
NewAttendancePeriodRequest,
NewAttendancePeriodResponse,
Response,
UpdateAttendancePeriodRequest,
)
app = MCPProxy(
contact={'x-twitter': 'PersonioHR'},
description='API for reading and writing personnel data incl. data about attendances and absences',
title='Personnel Data',
version='1.0',
servers=[{'url': 'https://api.personio.de/v1'}],
)
@app.get(
'/company/attendances',
description=""" This endpoint is responsible for fetching attendance data for the company employees. It is possible to paginate results, filter by period, the date and/or time it was updated, and/or specific employees. The result will contain a list of attendance periods, structured as defined here. """,
tags=['attendance_record_handling', 'employee_record_handling'],
)
def get_company_attendances(
start_date: date_aliased,
end_date: date_aliased = ...,
updated_from: Optional[str] = None,
updated_to: Optional[str] = None,
employees: Optional[Employees] = None,
limit: Optional[conint(ge=1)] = 200,
offset: Optional[conint(ge=0)] = 0,
):
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.post(
'/company/attendances',
description=""" This endpoint is responsible for adding attendance data for the company employees. It is possible to add attendances for one or many employees at the same time. The payload sent on the request should be a list of attendance periods, in the form of an array containing attendance period objects. """,
tags=['attendance_record_handling'],
)
def post_company_attendances(body: NewAttendancePeriodRequest):
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.delete(
'/company/attendances/{id}',
description=""" This endpoint is responsible for deleting attendance data for the company employees. """,
tags=['employee_record_handling'],
)
def delete_company_attendances__id(id: int):
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.patch(
'/company/attendances/{id}',
description=""" This endpoint is responsible for updating attendance data for the company employees. Attributes are not required and if not specified, the current value will be used. It is not possible to change the employee id. """,
tags=['attendance_record_handling'],
)
def patch_company_attendances__id(id: int, body: UpdateAttendancePeriodRequest = ...):
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/company/employees',
description=""" List Employees """,
tags=[
'attendance_record_handling',
'employee_record_handling',
'time_off_request_management',
],
)
def get_company_employees():
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.post(
'/company/employees',
description=""" Creates new employee. Status of the employee will be set to `active` if `hire_date` provided is in past. Otherwise status will be set to `onboarding`. This endpoint will respond with `id` of created employee in case of success.
""",
tags=['employee_record_handling'],
)
def post_company_employees(request: Request):
"""
Create an employee
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/company/employees/{employee_id}',
description=""" Show employee by ID """,
tags=['employee_record_handling'],
)
def get_company_employees__employee_id(employee_id: int):
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/company/employees/{employee_id}/profile-picture/{width}',
description=""" Show employee profile picture """,
tags=['employee_record_handling'],
)
def get_company_employees__employee_id_profile_picture__width(
employee_id: int, width: int = ...
):
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/company/time-off-types',
description=""" Provides a list of available time-off types, for example 'Paid vacation', 'Parental leave' or 'Home office' """,
tags=['attendance_record_handling', 'employee_record_handling'],
)
def get_company_time_off_types(
limit: Optional[conint(ge=1)] = 200, offset: Optional[conint(ge=0)] = 0
):
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/company/time-offs',
description=""" This endpoint is responsible for fetching absence data for the company employees. It is possible to paginate results, filter by period and/or specific employees. The result will contain a list of absence periods, structured as defined here. """,
tags=['attendance_record_handling', 'employee_record_handling'],
)
def get_company_time_offs(
start_date: Optional[date_aliased] = None,
end_date: Optional[date_aliased] = None,
updated_from: Optional[str] = None,
updated_to: Optional[str] = None,
employees: Optional[Employees] = None,
limit: Optional[conint(ge=1)] = 200,
offset: Optional[conint(ge=0)] = 0,
):
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.post(
'/company/time-offs',
description=""" This endpoint is responsible for adding absence data for the company employees. """,
tags=['time_off_request_management'],
)
def post_company_time_offs(body: CreateTimeOffPeriodRequest):
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.delete(
'/company/time-offs/{id}',
description=""" This endpoint is responsible for deleting absence period data for the company employees. """,
tags=['attendance_record_handling', 'employee_record_handling'],
)
def delete_company_time_offs__id(id: int):
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/company/time-offs/{id}',
description=""" Absence Period """,
tags=[
'attendance_record_handling',
'employee_record_handling',
'time_off_request_management',
],
)
def get_company_time_offs__id(id: int):
raise RuntimeError("Should be patched by MCPProxy and never executed")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="MCP Server")
parser.add_argument(
"transport",
choices=["stdio", "sse", "streamable-http"],
help="Transport mode (stdio, sse or streamable-http)",
)
args = parser.parse_args()
if "CONFIG_PATH" in os.environ:
config_path = os.environ["CONFIG_PATH"]
app.load_configuration(config_path)
if "CONFIG" in os.environ:
config = os.environ["CONFIG"]
app.load_configuration_from_string(config)
if "SECURITY" in os.environ:
security_params = BaseSecurity.parse_security_parameters_from_env(
os.environ,
)
app.set_security_params(security_params)
mcp_settings = json.loads(os.environ.get("MCP_SETTINGS", "{}"))
app.get_mcp(**mcp_settings).run(transport=args.transport)