@danyow/lark-mcp 0.5.1
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.
- package/CHANGELOG.md +62 -0
- package/LICENSE +9 -0
- package/README.md +215 -0
- package/README_ZH.md +212 -0
- package/dist/auth/config.d.ts +12 -0
- package/dist/auth/config.js +15 -0
- package/dist/auth/handler/handler-local.d.ts +21 -0
- package/dist/auth/handler/handler-local.js +123 -0
- package/dist/auth/handler/handler.d.ts +32 -0
- package/dist/auth/handler/handler.js +117 -0
- package/dist/auth/handler/index.d.ts +2 -0
- package/dist/auth/handler/index.js +18 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.js +20 -0
- package/dist/auth/provider/index.d.ts +3 -0
- package/dist/auth/provider/index.js +19 -0
- package/dist/auth/provider/oauth.d.ts +18 -0
- package/dist/auth/provider/oauth.js +147 -0
- package/dist/auth/provider/oidc.d.ts +18 -0
- package/dist/auth/provider/oidc.js +172 -0
- package/dist/auth/provider/types.d.ts +8 -0
- package/dist/auth/provider/types.js +2 -0
- package/dist/auth/store.d.ts +39 -0
- package/dist/auth/store.js +213 -0
- package/dist/auth/types.d.ts +13 -0
- package/dist/auth/types.js +2 -0
- package/dist/auth/utils/encryption.d.ts +7 -0
- package/dist/auth/utils/encryption.js +40 -0
- package/dist/auth/utils/index.d.ts +3 -0
- package/dist/auth/utils/index.js +19 -0
- package/dist/auth/utils/is-token-valid.d.ts +7 -0
- package/dist/auth/utils/is-token-valid.js +28 -0
- package/dist/auth/utils/pkce.d.ts +6 -0
- package/dist/auth/utils/pkce.js +20 -0
- package/dist/auth/utils/storage-manager.d.ts +17 -0
- package/dist/auth/utils/storage-manager.js +135 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +5 -0
- package/dist/cli/login-handler.d.ts +16 -0
- package/dist/cli/login-handler.js +142 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +122 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/mcp-server/index.d.ts +2 -0
- package/dist/mcp-server/index.js +18 -0
- package/dist/mcp-server/shared/index.d.ts +2 -0
- package/dist/mcp-server/shared/index.js +18 -0
- package/dist/mcp-server/shared/init.d.ts +10 -0
- package/dist/mcp-server/shared/init.js +121 -0
- package/dist/mcp-server/shared/types.d.ts +40 -0
- package/dist/mcp-server/shared/types.js +10 -0
- package/dist/mcp-server/transport/index.d.ts +3 -0
- package/dist/mcp-server/transport/index.js +19 -0
- package/dist/mcp-server/transport/sse.d.ts +2 -0
- package/dist/mcp-server/transport/sse.js +75 -0
- package/dist/mcp-server/transport/stdio.d.ts +2 -0
- package/dist/mcp-server/transport/stdio.js +36 -0
- package/dist/mcp-server/transport/streamable.d.ts +2 -0
- package/dist/mcp-server/transport/streamable.js +86 -0
- package/dist/mcp-server/transport/utils.d.ts +16 -0
- package/dist/mcp-server/transport/utils.js +34 -0
- package/dist/mcp-tool/constants.d.ts +49 -0
- package/dist/mcp-tool/constants.js +115 -0
- package/dist/mcp-tool/document-tool/index.d.ts +1 -0
- package/dist/mcp-tool/document-tool/index.js +17 -0
- package/dist/mcp-tool/document-tool/recall/index.d.ts +2 -0
- package/dist/mcp-tool/document-tool/recall/index.js +39 -0
- package/dist/mcp-tool/document-tool/recall/request.d.ts +2 -0
- package/dist/mcp-tool/document-tool/recall/request.js +25 -0
- package/dist/mcp-tool/document-tool/recall/type.d.ts +19 -0
- package/dist/mcp-tool/document-tool/recall/type.js +2 -0
- package/dist/mcp-tool/index.d.ts +5 -0
- package/dist/mcp-tool/index.js +21 -0
- package/dist/mcp-tool/mcp-tool.d.ts +52 -0
- package/dist/mcp-tool/mcp-tool.js +198 -0
- package/dist/mcp-tool/tools/en/builtin-tools/docx/builtin.d.ts +5 -0
- package/dist/mcp-tool/tools/en/builtin-tools/docx/builtin.js +219 -0
- package/dist/mcp-tool/tools/en/builtin-tools/drive/builtin.d.ts +4 -0
- package/dist/mcp-tool/tools/en/builtin-tools/drive/builtin.js +159 -0
- package/dist/mcp-tool/tools/en/builtin-tools/im/buildin.d.ts +4 -0
- package/dist/mcp-tool/tools/en/builtin-tools/im/buildin.js +63 -0
- package/dist/mcp-tool/tools/en/builtin-tools/index.d.ts +5 -0
- package/dist/mcp-tool/tools/en/builtin-tools/index.js +7 -0
- package/dist/mcp-tool/tools/en/gen-tools/index.d.ts +114 -0
- package/dist/mcp-tool/tools/en/gen-tools/index.js +129 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/acs_v1.d.ts +562 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/acs_v1.js +264 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/admin_v1.d.ts +912 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/admin_v1.js +449 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/aily_v1.d.ts +1213 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/aily_v1.js +560 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/apaas_v1.d.ts +2530 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/apaas_v1.js +949 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/application_v5.d.ts +80 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/application_v5.js +53 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/application_v6.d.ts +1008 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/application_v6.js +775 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/approval_v4.d.ts +3928 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/approval_v4.js +1602 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/attendance_v1.d.ts +6043 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/attendance_v1.js +1857 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/auth_v3.d.ts +151 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/auth_v3.js +71 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/authen_v1.d.ts +26 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/authen_v1.js +17 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/baike_v1.d.ts +2174 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/baike_v1.js +594 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/base_v2.d.ts +755 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/base_v2.js +234 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/bitable_v1.d.ts +3541 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/bitable_v1.js +1786 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/board_v1.d.ts +40 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/board_v1.js +18 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/calendar_v4.d.ts +2075 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/calendar_v4.js +1594 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/cardkit_v1.d.ts +528 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/cardkit_v1.js +260 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/compensation_v1.d.ts +189 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/compensation_v1.js +132 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/contact_v3.d.ts +4274 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/contact_v3.js +2583 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/corehr_v1.d.ts +16873 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/corehr_v1.js +5045 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/corehr_v2.d.ts +29387 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/corehr_v2.js +7787 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/directory_v1.d.ts +4274 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/directory_v1.js +1367 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/docs_v1.d.ts +58 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/docs_v1.js +28 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/docx_v1.d.ts +93466 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/docx_v1.js +14350 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/drive_v1.d.ts +3251 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/drive_v1.js +1422 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/drive_v2.d.ts +174 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/drive_v2.js +117 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/ehr_v1.d.ts +86 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/ehr_v1.js +48 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/event_v1.d.ts +44 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/event_v1.js +17 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/helpdesk_v1.d.ts +733 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/helpdesk_v1.js +285 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/hire_v1.d.ts +10076 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/hire_v1.js +6065 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/hire_v2.d.ts +158 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/hire_v2.js +61 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/human_authentication_v1.d.ts +70 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/human_authentication_v1.js +27 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/im_v1.d.ts +3043 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/im_v1.js +1869 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/im_v2.d.ts +2176 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/im_v2.js +460 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/lingo_v1.d.ts +2301 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/lingo_v1.js +669 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/mail_v1.d.ts +2462 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/mail_v1.js +1655 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/mdm_v1.d.ts +104 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/mdm_v1.js +45 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/mdm_v3.d.ts +329 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/mdm_v3.js +78 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/minutes_v1.d.ts +92 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/minutes_v1.js +62 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/moments_v1.d.ts +52 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/moments_v1.js +24 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/okr_v1.d.ts +1628 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/okr_v1.js +434 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/optical_char_recognition_v1.d.ts +38 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/optical_char_recognition_v1.js +17 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/passport_v1.d.ts +131 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/passport_v1.js +59 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/payroll_v1.d.ts +333 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/payroll_v1.js +176 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/performance_v1.d.ts +309 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/performance_v1.js +178 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/performance_v2.d.ts +1177 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/performance_v2.js +559 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/personal_settings_v1.d.ts +640 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/personal_settings_v1.js +303 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/report_v1.d.ts +192 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/report_v1.js +71 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/search_v2.d.ts +1695 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/search_v2.js +446 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/security_and_compliance_v1.d.ts +68 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/security_and_compliance_v1.js +32 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/sheets_v2.d.ts +523 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/sheets_v2.js +231 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/sheets_v3.d.ts +979 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/sheets_v3.js +721 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/speech_to_text_v1.d.ts +225 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/speech_to_text_v1.js +65 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/task_v1.d.ts +1161 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/task_v1.js +672 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/task_v2.d.ts +6051 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/task_v2.js +1970 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/tenant_v2.d.ts +31 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/tenant_v2.js +24 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/translation_v1.d.ts +80 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/translation_v1.js +37 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/trust_party_v1.d.ts +182 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/trust_party_v1.js +141 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/vc_v1.d.ts +5725 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/vc_v1.js +1751 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/verification_v1.d.ts +21 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/verification_v1.js +14 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/wiki_v1.d.ts +72 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/wiki_v1.js +19 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/wiki_v2.d.ts +843 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/wiki_v2.js +381 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/workplace_v1.d.ts +116 -0
- package/dist/mcp-tool/tools/en/gen-tools/zod/workplace_v1.js +77 -0
- package/dist/mcp-tool/tools/index.d.ts +104 -0
- package/dist/mcp-tool/tools/index.js +9 -0
- package/dist/mcp-tool/tools/zh/builtin-tools/docx/builtin.d.ts +5 -0
- package/dist/mcp-tool/tools/zh/builtin-tools/docx/builtin.js +198 -0
- package/dist/mcp-tool/tools/zh/builtin-tools/drive/builtin.d.ts +4 -0
- package/dist/mcp-tool/tools/zh/builtin-tools/drive/builtin.js +159 -0
- package/dist/mcp-tool/tools/zh/builtin-tools/im/buildin.d.ts +4 -0
- package/dist/mcp-tool/tools/zh/builtin-tools/im/buildin.js +63 -0
- package/dist/mcp-tool/tools/zh/builtin-tools/index.d.ts +5 -0
- package/dist/mcp-tool/tools/zh/builtin-tools/index.js +7 -0
- package/dist/mcp-tool/tools/zh/gen-tools/index.d.ts +114 -0
- package/dist/mcp-tool/tools/zh/gen-tools/index.js +129 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/acs_v1.d.ts +562 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/acs_v1.js +277 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/admin_v1.d.ts +912 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/admin_v1.js +430 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/aily_v1.d.ts +1213 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/aily_v1.js +541 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/apaas_v1.d.ts +2530 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/apaas_v1.js +885 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/application_v5.d.ts +80 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/application_v5.js +59 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/application_v6.d.ts +1007 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/application_v6.js +721 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/approval_v4.d.ts +3928 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/approval_v4.js +1532 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/attendance_v1.d.ts +6043 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/attendance_v1.js +1620 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/auth_v3.d.ts +151 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/auth_v3.js +87 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/authen_v1.d.ts +26 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/authen_v1.js +17 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/baike_v1.d.ts +2174 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/baike_v1.js +574 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/base_v2.d.ts +755 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/base_v2.js +270 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/bitable_v1.d.ts +3541 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/bitable_v1.js +1864 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/board_v1.d.ts +40 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/board_v1.js +18 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/calendar_v4.d.ts +2075 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/calendar_v4.js +1533 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/cardkit_v1.d.ts +528 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/cardkit_v1.js +248 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/compensation_v1.d.ts +189 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/compensation_v1.js +130 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/contact_v3.d.ts +4274 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/contact_v3.js +2394 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/corehr_v1.d.ts +16957 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/corehr_v1.js +4753 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/corehr_v2.d.ts +29869 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/corehr_v2.js +7902 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/directory_v1.d.ts +4324 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/directory_v1.js +1340 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/docs_v1.d.ts +58 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/docs_v1.js +26 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/docx_v1.d.ts +116719 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/docx_v1.js +14949 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/drive_v1.d.ts +3251 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/drive_v1.js +1395 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/drive_v2.d.ts +174 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/drive_v2.js +115 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/ehr_v1.d.ts +86 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/ehr_v1.js +48 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/event_v1.d.ts +44 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/event_v1.js +25 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/helpdesk_v1.d.ts +733 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/helpdesk_v1.js +279 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/hire_v1.d.ts +10085 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/hire_v1.js +5787 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/hire_v2.d.ts +158 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/hire_v2.js +64 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/human_authentication_v1.d.ts +70 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/human_authentication_v1.js +27 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/im_v1.d.ts +3043 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/im_v1.js +1812 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/im_v2.d.ts +2176 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/im_v2.js +454 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/lingo_v1.d.ts +2301 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/lingo_v1.js +650 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/mail_v1.d.ts +2465 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/mail_v1.js +1467 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/mdm_v1.d.ts +104 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/mdm_v1.js +45 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/mdm_v3.d.ts +329 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/mdm_v3.js +76 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/minutes_v1.d.ts +92 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/minutes_v1.js +62 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/moments_v1.d.ts +52 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/moments_v1.js +20 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/okr_v1.d.ts +1664 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/okr_v1.js +455 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/optical_char_recognition_v1.d.ts +38 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/optical_char_recognition_v1.js +17 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/passport_v1.d.ts +131 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/passport_v1.js +53 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/payroll_v1.d.ts +609 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/payroll_v1.js +321 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/performance_v1.d.ts +309 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/performance_v1.js +165 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/performance_v2.d.ts +1177 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/performance_v2.js +525 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/personal_settings_v1.d.ts +640 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/personal_settings_v1.js +295 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/report_v1.d.ts +194 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/report_v1.js +72 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/search_v2.d.ts +1695 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/search_v2.js +556 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/security_and_compliance_v1.d.ts +68 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/security_and_compliance_v1.js +32 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/sheets_v2.d.ts +523 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/sheets_v2.js +231 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/sheets_v3.d.ts +979 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/sheets_v3.js +821 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/speech_to_text_v1.d.ts +225 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/speech_to_text_v1.js +65 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/task_v1.d.ts +1161 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/task_v1.js +647 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/task_v2.d.ts +6077 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/task_v2.js +1894 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/tenant_v2.d.ts +31 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/tenant_v2.js +24 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/translation_v1.d.ts +80 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/translation_v1.js +37 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/trust_party_v1.d.ts +182 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/trust_party_v1.js +137 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/vc_v1.d.ts +5725 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/vc_v1.js +1640 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/verification_v1.d.ts +21 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/verification_v1.js +14 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/wiki_v1.d.ts +72 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/wiki_v1.js +34 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/wiki_v2.d.ts +843 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/wiki_v2.js +376 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/workplace_v1.d.ts +116 -0
- package/dist/mcp-tool/tools/zh/gen-tools/zod/workplace_v1.js +77 -0
- package/dist/mcp-tool/types/index.d.ts +53 -0
- package/dist/mcp-tool/types/index.js +9 -0
- package/dist/mcp-tool/utils/case-transf.d.ts +2 -0
- package/dist/mcp-tool/utils/case-transf.js +15 -0
- package/dist/mcp-tool/utils/filter-tools.d.ts +2 -0
- package/dist/mcp-tool/utils/filter-tools.js +27 -0
- package/dist/mcp-tool/utils/get-should-use-uat.d.ts +2 -0
- package/dist/mcp-tool/utils/get-should-use-uat.js +18 -0
- package/dist/mcp-tool/utils/handler.d.ts +2 -0
- package/dist/mcp-tool/utils/handler.js +119 -0
- package/dist/mcp-tool/utils/index.d.ts +4 -0
- package/dist/mcp-tool/utils/index.js +20 -0
- package/dist/utils/clean-env-args.d.ts +1 -0
- package/dist/utils/clean-env-args.js +12 -0
- package/dist/utils/constants.d.ts +18 -0
- package/dist/utils/constants.js +35 -0
- package/dist/utils/http-instance.d.ts +2 -0
- package/dist/utils/http-instance.js +21 -0
- package/dist/utils/logger.d.ts +22 -0
- package/dist/utils/logger.js +97 -0
- package/dist/utils/noop.d.ts +1 -0
- package/dist/utils/noop.js +6 -0
- package/dist/utils/parser-string-array.d.ts +1 -0
- package/dist/utils/parser-string-array.js +13 -0
- package/dist/utils/safe-json-parse.d.ts +1 -0
- package/dist/utils/safe-json-parse.js +14 -0
- package/dist/utils/version.d.ts +1 -0
- package/dist/utils/version.js +52 -0
- package/docs/recall-mcp/README.md +137 -0
- package/docs/recall-mcp/README_ZH.md +137 -0
- package/docs/reference/cli/cli-zh.md +92 -0
- package/docs/reference/cli/cli.md +92 -0
- package/docs/reference/tool-presets/presets-zh.md +120 -0
- package/docs/reference/tool-presets/presets.md +120 -0
- package/docs/reference/tool-presets/tools-en.md +1527 -0
- package/docs/reference/tool-presets/tools-zh.md +1544 -0
- package/docs/troubleshooting/faq-zh.md +67 -0
- package/docs/troubleshooting/faq.md +67 -0
- package/docs/usage/configuration/configuration-zh.md +344 -0
- package/docs/usage/configuration/configuration.md +344 -0
- package/docs/usage/docker/docker-zh.md +101 -0
- package/docs/usage/docker/docker.md +106 -0
- package/package.json +65 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# 0.5.1
|
|
2
|
+
- Fix: 修复login再次登录的时候没有正确唤起授权
|
|
3
|
+
|
|
4
|
+
- Fix: Resolved the issue where the authorization process was not properly triggered during re-login.
|
|
5
|
+
|
|
6
|
+
# 0.5.0
|
|
7
|
+
- Feat: 使用Login登录会自动用浏览器打开登录链接,且login不在会判断是否已经登录,再次登录会直接用新的token覆盖旧的token
|
|
8
|
+
- Fix: SSE/Streamable 模式下未开启oauth错误需要鉴权流程的问题
|
|
9
|
+
- Chore:优化鉴权失败的文案,和 keytar 不可用时的文案
|
|
10
|
+
- Chore: 同步最新Open API, 移除了Helpdesk部分不可用的API
|
|
11
|
+
|
|
12
|
+
- Feat: Using Login to log in will automatically open the login link in the browser, and if login is not present, it will check whether you have already logged in. Logging in again will directly overwrite the old token with a new one.
|
|
13
|
+
- Fix: The issue where the unopened oauth error in SSE/Streamable mode requires an authentication process.
|
|
14
|
+
- Chore: Optimize the copy for authentication failure and the copy when keytar is unavailable.
|
|
15
|
+
- Chore: Sync the latest Open API.
|
|
16
|
+
|
|
17
|
+
# 0.4.1
|
|
18
|
+
Fix: 开放平台开发文档检索 MCP 错误需要鉴权流程的问题
|
|
19
|
+
Fix: Fixed authentication process issue in Open Platform Development Documentation Retrieval MCP
|
|
20
|
+
|
|
21
|
+
# 0.4.0
|
|
22
|
+
Feat: 新增 StreamableHttp 的传输模式
|
|
23
|
+
Feat: StreamableHttp/SSE 支持 [MCP Auth](https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization)
|
|
24
|
+
Feat: Stdio(本地) 模式支持 login 和 logout 命令登录登出和自动使用 refresh_token 刷新
|
|
25
|
+
Fix: 修复 TokenMode=Auto 模式下没有设置UserAccessToken且CallTool传递参数useUAT=true依然使用应用身份
|
|
26
|
+
Bump: 升级 @modelcontextprotocol/sdk 到 1.12.1
|
|
27
|
+
BREAK: 由于升级了 @modelcontextprotocol/sdk,最低兼容 Node 版本调整为 Node 20
|
|
28
|
+
|
|
29
|
+
Feat: Added StreamableHttp transport mode
|
|
30
|
+
Feat: StreamableHttp/SSE supports [MCP Auth](https://modelcontextprotocol.io/specification/2025-03-26/basic/authorization)
|
|
31
|
+
Feat: Stdio (local) mode supports login and logout commands for authentication and automatic refresh_token renewal
|
|
32
|
+
Fix: Fixed issue where TokenMode=Auto would still use app identity when UserAccessToken is not set but CallTool parameter useUAT=true
|
|
33
|
+
Bump: Upgraded @modelcontextprotocol/sdk to 1.12.1
|
|
34
|
+
BREAK: Due to @modelcontextprotocol/sdk upgrade, minimum compatible Node version is now Node 20
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# 0.3.1
|
|
38
|
+
Fix: 修复使用 configFile 配置 mode 参数不生效的问题
|
|
39
|
+
Fix: 修复由于使用了z.record(z.any())类型的字段导致直接传给豆包模型无法使用的问题
|
|
40
|
+
Feat: 新增 preset.light 预设
|
|
41
|
+
|
|
42
|
+
Fix: Fix the problem that the mode parameter configured by configFile does not take effect
|
|
43
|
+
Fix: Fix the problem that the z.record(z.any()) type field is passed directly to the doubao model and cannot be used
|
|
44
|
+
Feat: Add preset.light preset
|
|
45
|
+
|
|
46
|
+
# 0.3.0
|
|
47
|
+
|
|
48
|
+
New: 开放平台开发文档检索 MCP,旨在帮助用户输入自身诉求后迅速检索到自己需要的开发文档,帮助开发者在AI IDE中编写与飞书集成的代码
|
|
49
|
+
New: 新增--token-mode,现在可以在启动的时候指定调用API的token类型,支持auto/tenant_access_token/user_access_token
|
|
50
|
+
New: -t 支持配置 preset.default preset.im.default preset.bitable.default preset.doc.default 等默认预设
|
|
51
|
+
Bump: 升级 @modelcontextprotocol/sdk 到 1.11.0
|
|
52
|
+
|
|
53
|
+
New:Retrieval of Open Platform Development Documents in MCP aims to enable users to quickly find the development documents they need after inputting their own requirements, and assist developers in writing code integrated with Feishu in the AI IDE.
|
|
54
|
+
New: Added --token-mode, now you can specify the API token type when starting, supporting auto/tenant_access_token/user_access_token
|
|
55
|
+
New: -t supports configuring preset.default preset.im.default preset.bitable.default preset.doc.default etc.
|
|
56
|
+
Bump: Upgraded @modelcontextprotocol/sdk to 1.11.0
|
|
57
|
+
|
|
58
|
+
# 0.2.0
|
|
59
|
+
|
|
60
|
+
飞书/Lark OpenAPI MCP 工具,可以帮助你快速开始使用MCP协议连接飞书/Lark,实现 Agent 与飞书/Lark平台的高效协作
|
|
61
|
+
|
|
62
|
+
Feishu/Lark OpenAPI MCP tool helps you quickly start using the MCP protocol to connect with Feishu/Lark, enabling efficient collaboration between Agent and the Feishu/Lark platform
|
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Lark Technologies Pte. Ltd.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice, shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Feishu/Lark OpenAPI MCP
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@larksuiteoapi/lark-mcp)
|
|
4
|
+
[](https://www.npmjs.com/package/@larksuiteoapi/lark-mcp)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
|
|
7
|
+
English | [中文](./README_ZH.md)
|
|
8
|
+
|
|
9
|
+
[Developer Documentation Retrieval MCP](./docs/recall-mcp/README.md)
|
|
10
|
+
|
|
11
|
+
[Official Document](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/mcp_introduction)
|
|
12
|
+
|
|
13
|
+
[Trouble Shooting](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/use_cases)
|
|
14
|
+
|
|
15
|
+
> **⚠️ Beta Version Notice**: This tool is currently in Beta stage. Features and APIs may change, so please stay updated with version releases.
|
|
16
|
+
|
|
17
|
+
This is the Feishu/Lark official OpenAPI MCP (Model Context Protocol) tool designed to help users quickly connect to the Feishu/Lark platform and enable efficient collaboration between AI Agents and Feishu/Lark. The tool encapsulates Feishu/Lark Open Platform API interfaces as MCP tools, allowing AI assistants to directly call these interfaces and implement various automation scenarios such as document processing, conversation management, calendar scheduling, and more.
|
|
18
|
+
|
|
19
|
+
## Preparation
|
|
20
|
+
|
|
21
|
+
### Creating a Feishu/Lark Application
|
|
22
|
+
|
|
23
|
+
Before using the lark-mcp tool, you need to create a Feishu/Lark application:
|
|
24
|
+
|
|
25
|
+
1. Visit the [Feishu Open Platform](https://open.feishu.cn/) or [Lark Open Platform](https://open.larksuite.com/) and log in
|
|
26
|
+
2. Click "Console" and create a new application
|
|
27
|
+
3. Obtain the App ID and App Secret, which will be used for API authentication
|
|
28
|
+
4. Add the necessary permissions for your application based on your usage scenario
|
|
29
|
+
5. If you need to call APIs as a user, set the OAuth 2.0 redirect URL to http://localhost:3000/callback
|
|
30
|
+
|
|
31
|
+
For detailed application creation and configuration guidelines, please refer to the [Feishu Open Platform Documentation - Creating an Application](https://open.feishu.cn/document/home/introduction-to-custom-app-development/self-built-application-development-process#a0a7f6b0).
|
|
32
|
+
|
|
33
|
+
### Installing Node.js
|
|
34
|
+
|
|
35
|
+
Before using the lark-mcp tool, you need to install the Node.js environment.
|
|
36
|
+
|
|
37
|
+
**Using the Official Installer (Recommended)**:
|
|
38
|
+
|
|
39
|
+
1. Visit the [Node.js website](https://nodejs.org/)
|
|
40
|
+
2. Download and install the LTS version
|
|
41
|
+
3. After installation, verify in the terminal:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
node -v
|
|
45
|
+
npm -v
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
### Using with Trae/Cursor/Claude
|
|
51
|
+
|
|
52
|
+
To integrate Feishu/Lark functionality in AI tools like Trae, Cursor or Claude, install using the button below.
|
|
53
|
+
|
|
54
|
+
[](https://cursor.com/install-mcp?name=lark-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBsYXJrc3VpdGVvYXBpL2xhcmstbWNwIiwibWNwIiwiLWEiLCJ5b3VyX2FwcF9pZCIsIi1zIiwieW91cl9hcHBfc2VjcmV0Il19)
|
|
55
|
+
|
|
56
|
+
[](trae-cn://trae.ai-ide/mcp-import?source=lark&type=stdio&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBsYXJrc3VpdGVvYXBpL2xhcmstbWNwIiwibWNwIiwiLWEiLCJ5b3VyX2FwcF9pZCIsIi1zIiwieW91cl9hcHBfc2VjcmV0Il19) [](trae://trae.ai-ide/mcp-import?source=lark&type=stdio&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBsYXJrc3VpdGVvYXBpL2xhcmstbWNwIiwibWNwIiwiLWEiLCJ5b3VyX2FwcF9pZCIsIi1zIiwieW91cl9hcHBfc2VjcmV0Il19)
|
|
57
|
+
|
|
58
|
+
or add the following to your configuration file:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"lark-mcp": {
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": [
|
|
66
|
+
"-y",
|
|
67
|
+
"@larksuiteoapi/lark-mcp",
|
|
68
|
+
"mcp",
|
|
69
|
+
"-a",
|
|
70
|
+
"<your_app_id>",
|
|
71
|
+
"-s",
|
|
72
|
+
"<your_app_secret>"
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
If you need to access APIs with **user identity**, you need to login first using the login command in the terminal. Note that you need to configure the application's redirect URL in the developer console first, default is http://localhost:3000/callback
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
|
|
83
|
+
# Login and get user access token
|
|
84
|
+
npx -y @larksuiteoapi/lark-mcp login -a cli_xxxx -s yyyyy
|
|
85
|
+
|
|
86
|
+
# Or optionally, login with specific OAuth scope - if not specified, all permissions will be authorized by default
|
|
87
|
+
npx -y @larksuiteoapi/lark-mcp login -a cli_xxxx -s yyyyy --scope offline_access docx:document
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Then add the following to your configuration file:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"mcpServers": {
|
|
96
|
+
"lark-mcp": {
|
|
97
|
+
"command": "npx",
|
|
98
|
+
"args": [
|
|
99
|
+
"-y",
|
|
100
|
+
"@larksuiteoapi/lark-mcp",
|
|
101
|
+
"mcp",
|
|
102
|
+
"-a",
|
|
103
|
+
"<your_app_id>",
|
|
104
|
+
"-s",
|
|
105
|
+
"<your_app_secret>",
|
|
106
|
+
"--oauth",
|
|
107
|
+
"--token-mode", "user_access_token"
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Note: When enabling `--oauth`, it's recommended to explicitly set `--token-mode` to `user_access_token`, which means calling APIs with user access tokens, suitable for accessing user resources or scenarios requiring user authorization (such as reading personal documents, sending IM messages). If you keep the default `auto`, some APIs AI may fallback to `tenant_access_token`, which could result in insufficient permissions or inability to access user private data.
|
|
115
|
+
|
|
116
|
+
### Domain Configuration
|
|
117
|
+
|
|
118
|
+
Based on your usage scenario, lark-mcp supports configuring different domain environments:
|
|
119
|
+
|
|
120
|
+
**Feishu (China Version)**:
|
|
121
|
+
- Default uses `https://open.feishu.cn` domain
|
|
122
|
+
- Suitable for users in China
|
|
123
|
+
|
|
124
|
+
**Lark (International Version)**:
|
|
125
|
+
- Uses `https://open.larksuite.com` domain
|
|
126
|
+
- Suitable for overseas users or international version of Lark
|
|
127
|
+
|
|
128
|
+
To switch to the international version of Lark, add the `--domain` parameter in your configuration:
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"mcpServers": {
|
|
133
|
+
"lark-mcp": {
|
|
134
|
+
"command": "npx",
|
|
135
|
+
"args": [
|
|
136
|
+
"-y",
|
|
137
|
+
"@larksuiteoapi/lark-mcp",
|
|
138
|
+
"mcp",
|
|
139
|
+
"-a",
|
|
140
|
+
"<your_app_id>",
|
|
141
|
+
"-s",
|
|
142
|
+
"<your_app_secret>",
|
|
143
|
+
"--domain",
|
|
144
|
+
"https://open.larksuite.com"
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
> **💡 Tip**: Ensure your application is created in the corresponding domain environment's open platform. International version applications cannot be used with Feishu China version, and vice versa.
|
|
152
|
+
|
|
153
|
+
## Custom API Configuration
|
|
154
|
+
|
|
155
|
+
> ⚠️ **File Upload/Download**: File upload and download operations are not yet supported
|
|
156
|
+
|
|
157
|
+
> ⚠️ **Document Editing**: Direct editing of Feishu cloud documents is not supported (only importing and reading are available)
|
|
158
|
+
|
|
159
|
+
By default, the MCP service enables common APIs. To enable other tools or only specific APIs or presets, you can specify them using the `-t` parameter in the MCP Client configuration (JSON):
|
|
160
|
+
|
|
161
|
+
```json
|
|
162
|
+
{
|
|
163
|
+
"mcpServers": {
|
|
164
|
+
"lark-mcp": {
|
|
165
|
+
"command": "npx",
|
|
166
|
+
"args": [
|
|
167
|
+
"-y",
|
|
168
|
+
"@larksuiteoapi/lark-mcp",
|
|
169
|
+
"mcp",
|
|
170
|
+
"-a", "<your_app_id>",
|
|
171
|
+
"-s", "<your_app_secret>",
|
|
172
|
+
"-t", "im.v1.message.create,im.v1.message.list,im.v1.chat.create,preset.calendar.default"
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
For detailed information about all preset tool collections and which tools are included in each preset, please refer to the [Preset Tool Collections Reference](./docs/reference/tool-presets/presets.md).
|
|
180
|
+
|
|
181
|
+
A complete list of all supported Feishu/Lark tools can be found in [tools.md](./docs/reference/tool-presets/tools-en.md).
|
|
182
|
+
|
|
183
|
+
> **⚠️ Notice**:Non-preset APIs have not undergone compatibility testing, and the AI may not perform optimally during the process of understanding and using them.
|
|
184
|
+
|
|
185
|
+
### Development Integration
|
|
186
|
+
|
|
187
|
+
Developers can refer to the minimal example for integrating with Agent: [`lark-samples/mcp_quick_demo`](https://github.com/larksuite/lark-samples/tree/main/mcp_quick_demo).
|
|
188
|
+
|
|
189
|
+
You can also refer to the Lark bot integration example: [`lark-samples/mcp_larkbot_demo/nodejs`](https://github.com/larksuite/lark-samples/tree/main/mcp_larkbot_demo/nodejs).
|
|
190
|
+
|
|
191
|
+
This example demonstrates how to integrate MCP capabilities into Feishu/Lark bots, triggering tool calls and message sending through bot conversations, suitable for scenarios that integrate existing tools into Bot.
|
|
192
|
+
|
|
193
|
+
### Advanced Configuration
|
|
194
|
+
|
|
195
|
+
For detailed configuration options and deployment scenarios, please refer to our [Configuration Guide](./docs/usage/configuration/configuration.md).
|
|
196
|
+
|
|
197
|
+
For detailed information about all available command line parameters and their usage, please refer to the [Command Line Reference](./docs/reference/cli/cli.md).
|
|
198
|
+
|
|
199
|
+
## FAQ
|
|
200
|
+
|
|
201
|
+
- [FAQ (Frequently Asked Questions)](./docs/troubleshooting/faq.md)
|
|
202
|
+
- [Common Issues and Use Cases](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/use_cases)
|
|
203
|
+
|
|
204
|
+
## Related Links
|
|
205
|
+
|
|
206
|
+
- [Feishu Open Platform](https://open.feishu.cn/)
|
|
207
|
+
- [Development Documentation: OpenAPI MCP](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/mcp_introduction)
|
|
208
|
+
- [Lark International Open Platform](https://open.larksuite.com/)
|
|
209
|
+
- [Feishu Open Platform API Documentation](https://open.feishu.cn/document/home/index)
|
|
210
|
+
- [Node.js Website](https://nodejs.org/)
|
|
211
|
+
- [npm Documentation](https://docs.npmjs.com/)
|
|
212
|
+
|
|
213
|
+
## Feedback
|
|
214
|
+
|
|
215
|
+
Issues are welcome to help improve this tool. If you have any questions or suggestions, please raise them in the GitHub repository.
|
package/README_ZH.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# 飞书/Lark OpenAPI MCP
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@larksuiteoapi/lark-mcp)
|
|
4
|
+
[](https://www.npmjs.com/package/@larksuiteoapi/lark-mcp)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
|
|
7
|
+
中文 | [English](./README.md)
|
|
8
|
+
|
|
9
|
+
[开发文档检索 MCP](./docs/recall-mcp/README_ZH.md)
|
|
10
|
+
|
|
11
|
+
[官方文档](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/mcp_introduction)
|
|
12
|
+
|
|
13
|
+
[常见问题](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/use_cases)
|
|
14
|
+
|
|
15
|
+
> **⚠️ Beta版本提示**:当前工具处于Beta版本阶段,功能和API可能会有变更,请密切关注版本更新。
|
|
16
|
+
|
|
17
|
+
飞书/Lark官方 OpenAPI MCP(Model Context Protocol)工具,旨在帮助用户快速连接飞书平台并实现 AI Agent 与飞书的高效协作。该工具将飞书开放平台的 API 接口封装为 MCP 工具,使 AI 助手能够直接调用这些接口,实现文档处理、会话管理、日历安排等多种自动化场景。
|
|
18
|
+
|
|
19
|
+
## 使用准备
|
|
20
|
+
|
|
21
|
+
### 创建应用
|
|
22
|
+
|
|
23
|
+
在使用lark-mcp工具前,您需要先创建一个飞书应用:
|
|
24
|
+
|
|
25
|
+
1. 访问[飞书开放平台](https://open.feishu.cn/)并登录
|
|
26
|
+
2. 点击"开发者后台",创建一个新应用
|
|
27
|
+
3. 获取应用的App ID和App Secret,这将用于API认证
|
|
28
|
+
4. 根据您的使用场景,为应用添加所需的权限
|
|
29
|
+
5. 如需以用户身份调用API,请设置OAuth 2.0重定向URL为 http://localhost:3000/callback
|
|
30
|
+
|
|
31
|
+
详细的应用创建和配置指南,请参考[飞书开放平台文档 - 创建应用](https://open.feishu.cn/document/home/introduction-to-custom-app-development/self-built-application-development-process#a0a7f6b0)。
|
|
32
|
+
|
|
33
|
+
### 安装Node.js
|
|
34
|
+
|
|
35
|
+
在使用lark-mcp工具之前,您需要先安装Node.js环境。
|
|
36
|
+
|
|
37
|
+
**使用官方安装包(推荐)**:
|
|
38
|
+
|
|
39
|
+
1. 访问[Node.js官网](https://nodejs.org/)
|
|
40
|
+
2. 下载并安装LTS版本
|
|
41
|
+
3. 安装完成后,打开终端验证:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
node -v
|
|
45
|
+
npm -v
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 快速开始
|
|
49
|
+
|
|
50
|
+
### 在Trae/Cursor中使用
|
|
51
|
+
|
|
52
|
+
如需在Trae、Cursor等AI工具中集成飞书/Lark功能,你可以通过下方按钮安装,将 `app_id` 和 `app_secret` 填入安装弹窗或客户端配置 JSON 的 `args` 中:
|
|
53
|
+
|
|
54
|
+
[](https://cursor.com/install-mcp?name=lark-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBsYXJrc3VpdGVvYXBpL2xhcmstbWNwIiwibWNwIiwiLWEiLCJ5b3VyX2FwcF9pZCIsIi1zIiwieW91cl9hcHBfc2VjcmV0Il19)
|
|
55
|
+
[](trae-cn://trae.ai-ide/mcp-import?source=lark&type=stdio&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBsYXJrc3VpdGVvYXBpL2xhcmstbWNwIiwibWNwIiwiLWEiLCJ5b3VyX2FwcF9pZCIsIi1zIiwieW91cl9hcHBfc2VjcmV0Il19) [](trae://trae.ai-ide/mcp-import?source=lark&type=stdio&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBsYXJrc3VpdGVvYXBpL2xhcmstbWNwIiwibWNwIiwiLWEiLCJ5b3VyX2FwcF9pZCIsIi1zIiwieW91cl9hcHBfc2VjcmV0Il19)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
也可以直接在 MCP Client 的配置文件中添加以下内容(JSON),客户端会按配置启动 `lark-mcp`:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"lark-mcp": {
|
|
64
|
+
"command": "npx",
|
|
65
|
+
"args": [
|
|
66
|
+
"-y",
|
|
67
|
+
"@larksuiteoapi/lark-mcp",
|
|
68
|
+
"mcp",
|
|
69
|
+
"-a",
|
|
70
|
+
"<your_app_id>",
|
|
71
|
+
"-s",
|
|
72
|
+
"<your_app_secret>"
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
如需使用**用户身份**访问 API:
|
|
80
|
+
1) 在终端运行 `login`(会保存令牌,后续客户端可直接复用)。
|
|
81
|
+
2) 在 MCP Client 配置中加入 `--oauth`。
|
|
82
|
+
|
|
83
|
+
注意需要先在开发者后台配置应用的重定向 URL,默认是 `http://localhost:3000/callback`。
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npx -y @larksuiteoapi/lark-mcp login -a cli_xxxx -s yyyyy
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
然后在 MCP Client 中启用 `--oauth`
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"mcpServers": {
|
|
94
|
+
"lark-mcp": {
|
|
95
|
+
"command": "npx",
|
|
96
|
+
"args": [
|
|
97
|
+
"-y",
|
|
98
|
+
"@larksuiteoapi/lark-mcp",
|
|
99
|
+
"mcp",
|
|
100
|
+
"-a", "<your_app_id>",
|
|
101
|
+
"-s", "<your_app_secret>",
|
|
102
|
+
"--oauth",
|
|
103
|
+
"--token-mode", "user_access_token"
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
说明:在启用 `--oauth` 时,建议显式设置 `--token-mode` 为 `user_access_token`,表示以用户访问令牌调用 API,适用于访问用户资源或需要用户授权的场景(如读取个人文档、发送 IM 消息)。若保留默认 `auto`,可能在AI推理使用 `tenant_access_token`,导致权限不足或无法访问用户私有数据。
|
|
111
|
+
|
|
112
|
+
### 域名配置
|
|
113
|
+
|
|
114
|
+
根据您的使用场景,lark-mcp 支持配置不同的域名环境:
|
|
115
|
+
|
|
116
|
+
**飞书**:
|
|
117
|
+
- 默认使用 `https://open.feishu.cn` 域名
|
|
118
|
+
- 适用于飞书用户
|
|
119
|
+
|
|
120
|
+
**Lark(国际版)**:
|
|
121
|
+
- 使用 `https://open.larksuite.com` 域名
|
|
122
|
+
- 适用于国际版Lark用户
|
|
123
|
+
|
|
124
|
+
如需切换至国际版Lark,请在配置中添加 `--domain` 参数:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"mcpServers": {
|
|
129
|
+
"lark-mcp": {
|
|
130
|
+
"command": "npx",
|
|
131
|
+
"args": [
|
|
132
|
+
"-y",
|
|
133
|
+
"@larksuiteoapi/lark-mcp",
|
|
134
|
+
"mcp",
|
|
135
|
+
"-a",
|
|
136
|
+
"<your_app_id>",
|
|
137
|
+
"-s",
|
|
138
|
+
"<your_app_secret>",
|
|
139
|
+
"--domain",
|
|
140
|
+
"https://open.larksuite.com"
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> **💡 提示**:确保您的应用已在对应域名环境的开放平台创建。国际版应用无法在飞书中国版使用,反之亦然。
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
## 自定义配置开启API
|
|
151
|
+
|
|
152
|
+
> ⚠️ **文件上传下载**:暂不支持文件的上传和下载操作
|
|
153
|
+
|
|
154
|
+
> ⚠️ **云文档编辑**:暂不支持直接编辑飞书云文档内容(仅支持导入和读取)
|
|
155
|
+
|
|
156
|
+
默认情况下,MCP 服务启用常用 API。如需启用其他工具或仅启用特定 API 或 preset,推荐在 MCP Client 配置(JSON)中通过 `-t` 指定(用逗号分隔):
|
|
157
|
+
|
|
158
|
+
```json
|
|
159
|
+
{
|
|
160
|
+
"mcpServers": {
|
|
161
|
+
"lark-mcp": {
|
|
162
|
+
"command": "npx",
|
|
163
|
+
"args": [
|
|
164
|
+
"-y",
|
|
165
|
+
"@larksuiteoapi/lark-mcp",
|
|
166
|
+
"mcp",
|
|
167
|
+
"-a", "<your_app_id>",
|
|
168
|
+
"-s", "<your_app_secret>",
|
|
169
|
+
"-t", "im.v1.message.create,im.v1.message.list,im.v1.chat.create,preset.calendar.default"
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
关于所有预设工具集的详细信息以及每个预设包含哪些工具,请参考[预设工具集参考文档](./docs/reference/tool-presets/presets-zh.md)。
|
|
177
|
+
|
|
178
|
+
对于所有支持的飞书/Lark工具列表可以在[tools.md](./docs/reference/tool-presets/tools-zh.md)中查看。
|
|
179
|
+
|
|
180
|
+
> **⚠️ 提示**:非预设 API 没有经过兼容性测试,AI在理解使用的过程中可能效果不理想
|
|
181
|
+
|
|
182
|
+
### 在开发Agent中使用
|
|
183
|
+
|
|
184
|
+
开发者可参考在 Agent 中集成的最小示例:[`lark-samples/mcp_quick_demo`](https://github.com/larksuite/lark-samples/tree/main/mcp_quick_demo)。
|
|
185
|
+
|
|
186
|
+
另外可参考 Lark 机器人集成示例:[`lark-samples/mcp_larkbot_demo/nodejs`](https://github.com/larksuite/lark-samples/tree/main/mcp_larkbot_demo/nodejs)。
|
|
187
|
+
|
|
188
|
+
该示例展示如何将 MCP 能力集成到飞书/Lark 机器人中,通过机器人会话触发工具调用与消息收发,适用于将已有工具接入 Bot 的场景。
|
|
189
|
+
|
|
190
|
+
### 高级配置
|
|
191
|
+
|
|
192
|
+
更详细的配置选项和部署场景,请参考我们的[配置指南](./docs/usage/configuration/configuration-zh.md)。
|
|
193
|
+
|
|
194
|
+
关于所有可用命令行参数及其使用方法的详细信息,请参考[命令行参考文档](./docs/reference/cli/cli-zh.md)。
|
|
195
|
+
|
|
196
|
+
## 常见问题
|
|
197
|
+
|
|
198
|
+
- [常见问题(FAQ)](./docs/troubleshooting/faq-zh.md)
|
|
199
|
+
- [常见问题与使用案例](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/use_cases)
|
|
200
|
+
|
|
201
|
+
## 相关链接
|
|
202
|
+
|
|
203
|
+
- [飞书开放平台](https://open.feishu.cn/)
|
|
204
|
+
- [开发文档:OpenAPI MCP](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/mcp_integration/mcp_introduction)
|
|
205
|
+
- [Lark国际版开放平台](https://open.larksuite.com/)
|
|
206
|
+
- [飞书开放平台API文档](https://open.feishu.cn/document/home/index)
|
|
207
|
+
- [Node.js官网](https://nodejs.org/)
|
|
208
|
+
- [npm文档](https://docs.npmjs.com/)
|
|
209
|
+
|
|
210
|
+
## 反馈
|
|
211
|
+
|
|
212
|
+
欢迎提交Issues来帮助改进这个工具。如有问题或建议,请在GitHub仓库中提出。
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const AUTH_CONFIG: {
|
|
2
|
+
readonly SERVER_NAME: "lark-mcp";
|
|
3
|
+
readonly AES_KEY_NAME: "encryption-key";
|
|
4
|
+
readonly STORAGE_DIR: string;
|
|
5
|
+
readonly STORAGE_FILE: "storage.json";
|
|
6
|
+
readonly ENCRYPTION: {
|
|
7
|
+
readonly ALGORITHM: "aes-256-cbc";
|
|
8
|
+
readonly KEY_LENGTH: 32;
|
|
9
|
+
readonly IV_LENGTH: 16;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export type AuthConfig = typeof AUTH_CONFIG;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AUTH_CONFIG = void 0;
|
|
4
|
+
const constants_1 = require("../utils/constants");
|
|
5
|
+
exports.AUTH_CONFIG = {
|
|
6
|
+
SERVER_NAME: 'lark-mcp',
|
|
7
|
+
AES_KEY_NAME: 'encryption-key',
|
|
8
|
+
STORAGE_DIR: constants_1.ENV_PATHS.data,
|
|
9
|
+
STORAGE_FILE: 'storage.json',
|
|
10
|
+
ENCRYPTION: {
|
|
11
|
+
ALGORITHM: 'aes-256-cbc',
|
|
12
|
+
KEY_LENGTH: 32, // 256 bits
|
|
13
|
+
IV_LENGTH: 16, // 128 bits
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
import { LarkAuthHandler } from './handler';
|
|
3
|
+
export declare class LarkAuthHandlerLocal extends LarkAuthHandler {
|
|
4
|
+
private static readonly LOCAL_CLIENT_ID;
|
|
5
|
+
private expressServer;
|
|
6
|
+
private timeoutId;
|
|
7
|
+
private startServer;
|
|
8
|
+
private stopServer;
|
|
9
|
+
protected callback(req: Request, res: Response): Promise<void>;
|
|
10
|
+
refreshToken(accessToken: string): Promise<{
|
|
11
|
+
access_token: string;
|
|
12
|
+
token_type: string;
|
|
13
|
+
expires_in?: number | undefined;
|
|
14
|
+
scope?: string | undefined;
|
|
15
|
+
refresh_token?: string | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
reAuthorize(accessToken?: string, ignoreCheck?: boolean): Promise<{
|
|
18
|
+
accessToken: string;
|
|
19
|
+
authorizeUrl: string;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LarkAuthHandlerLocal = void 0;
|
|
4
|
+
const handler_1 = require("./handler");
|
|
5
|
+
const store_1 = require("../store");
|
|
6
|
+
const is_token_valid_1 = require("../utils/is-token-valid");
|
|
7
|
+
const pkce_1 = require("../utils/pkce");
|
|
8
|
+
const logger_1 = require("../../utils/logger");
|
|
9
|
+
class LarkAuthHandlerLocal extends handler_1.LarkAuthHandler {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.expressServer = null;
|
|
13
|
+
this.timeoutId = null;
|
|
14
|
+
}
|
|
15
|
+
async startServer() {
|
|
16
|
+
if (this.expressServer) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
logger_1.logger.info(`[LarkAuthHandlerLocal] Starting server on ${this.options.host}:${this.options.port}`);
|
|
21
|
+
this.expressServer = this.app.listen(this.options.port, this.options.host, (error) => {
|
|
22
|
+
if (error) {
|
|
23
|
+
reject(error);
|
|
24
|
+
}
|
|
25
|
+
logger_1.logger.info(`[LarkAuthHandlerLocal] Server started on ${this.options.host}:${this.options.port}`);
|
|
26
|
+
resolve(true);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async stopServer() {
|
|
31
|
+
if (this.timeoutId) {
|
|
32
|
+
clearTimeout(this.timeoutId);
|
|
33
|
+
this.timeoutId = null;
|
|
34
|
+
}
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
if (!this.expressServer) {
|
|
37
|
+
resolve(true);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
logger_1.logger.info(`[LarkAuthHandlerLocal] Stopping server`);
|
|
41
|
+
this.expressServer.close((error) => {
|
|
42
|
+
if (error) {
|
|
43
|
+
reject(error);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
logger_1.logger.info(`[LarkAuthHandlerLocal] Server stopped`);
|
|
47
|
+
resolve(true);
|
|
48
|
+
}
|
|
49
|
+
this.expressServer = null;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async callback(req, res) {
|
|
54
|
+
if (!req.query.code || typeof req.query.code !== 'string') {
|
|
55
|
+
logger_1.logger.error(`[LarkAuthHandlerLocal] callback: Failed to exchange authorization code: ${req.query.code}`);
|
|
56
|
+
res.end('error, failed to exchange authorization code, please try again');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const codeVerifier = store_1.authStore.getCodeVerifier(LarkAuthHandlerLocal.LOCAL_CLIENT_ID);
|
|
60
|
+
if (!codeVerifier) {
|
|
61
|
+
logger_1.logger.error(`[LarkAuthHandlerLocal] callback: Code verifier not found`);
|
|
62
|
+
res.end('error: code_verifier not found, please try again');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const token = await this.provider.exchangeAuthorizationCode({ client_id: LarkAuthHandlerLocal.LOCAL_CLIENT_ID, redirect_uris: [] }, req.query.code, codeVerifier, this.callbackUrl);
|
|
66
|
+
store_1.authStore.removeCodeVerifier(LarkAuthHandlerLocal.LOCAL_CLIENT_ID);
|
|
67
|
+
await store_1.authStore.storeLocalAccessToken(token.access_token, this.options.appId);
|
|
68
|
+
logger_1.logger.info(`[LarkAuthHandlerLocal] callback: Successfully exchanged authorization code`);
|
|
69
|
+
res.end('success, you can close this page now');
|
|
70
|
+
setTimeout(async () => {
|
|
71
|
+
try {
|
|
72
|
+
await this.stopServer();
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
logger_1.logger.error(`[LarkAuthHandlerLocal] callback: Error stopping server: ${error}`);
|
|
76
|
+
}
|
|
77
|
+
}, 1000);
|
|
78
|
+
}
|
|
79
|
+
async refreshToken(accessToken) {
|
|
80
|
+
const newToken = await super.refreshToken(accessToken);
|
|
81
|
+
await store_1.authStore.storeLocalAccessToken(newToken.access_token, this.options.appId);
|
|
82
|
+
return newToken;
|
|
83
|
+
}
|
|
84
|
+
async reAuthorize(accessToken, ignoreCheck = false) {
|
|
85
|
+
var _a;
|
|
86
|
+
const localAccessToken = await store_1.authStore.getLocalAccessToken(this.options.appId);
|
|
87
|
+
const { valid } = await (0, is_token_valid_1.isTokenValid)(localAccessToken);
|
|
88
|
+
if (ignoreCheck || accessToken === localAccessToken || !localAccessToken || !valid) {
|
|
89
|
+
const scope = (_a = this.options.scope) === null || _a === void 0 ? void 0 : _a.join(' ');
|
|
90
|
+
logger_1.logger.info(`[LarkAuthHandlerLocal] reAuthorize: Registering client`);
|
|
91
|
+
await store_1.authStore.registerClient({
|
|
92
|
+
client_id: LarkAuthHandlerLocal.LOCAL_CLIENT_ID,
|
|
93
|
+
client_secret: LarkAuthHandlerLocal.LOCAL_CLIENT_ID,
|
|
94
|
+
scope,
|
|
95
|
+
redirect_uris: [this.callbackUrl],
|
|
96
|
+
});
|
|
97
|
+
await this.startServer();
|
|
98
|
+
if (this.timeoutId) {
|
|
99
|
+
clearTimeout(this.timeoutId);
|
|
100
|
+
}
|
|
101
|
+
this.timeoutId = setTimeout(() => this.stopServer(), 60 * 1000);
|
|
102
|
+
const { codeVerifier, codeChallenge } = (0, pkce_1.generatePKCEPair)();
|
|
103
|
+
store_1.authStore.storeCodeVerifier(LarkAuthHandlerLocal.LOCAL_CLIENT_ID, codeVerifier);
|
|
104
|
+
const authorizeUrl = new URL(`http://${this.options.host}:${this.options.port}/authorize`);
|
|
105
|
+
authorizeUrl.searchParams.set('client_id', LarkAuthHandlerLocal.LOCAL_CLIENT_ID);
|
|
106
|
+
authorizeUrl.searchParams.set('response_type', 'code');
|
|
107
|
+
authorizeUrl.searchParams.set('code_challenge', codeChallenge);
|
|
108
|
+
authorizeUrl.searchParams.set('code_challenge_method', 'S256');
|
|
109
|
+
authorizeUrl.searchParams.set('redirect_uri', this.callbackUrl);
|
|
110
|
+
authorizeUrl.searchParams.set('state', 'reauthorize');
|
|
111
|
+
if (scope) {
|
|
112
|
+
authorizeUrl.searchParams.set('scope', scope);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
accessToken: '',
|
|
116
|
+
authorizeUrl: authorizeUrl.toString(),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return { accessToken: localAccessToken, authorizeUrl: '' };
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.LarkAuthHandlerLocal = LarkAuthHandlerLocal;
|
|
123
|
+
LarkAuthHandlerLocal.LOCAL_CLIENT_ID = 'client_id_for_local_auth';
|