@yoonion/mimi-seed-mcp 0.21.8 → 0.22.0
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/README.md +2 -1
- package/assets/agent-guide.md +1 -0
- package/dist/auth/drive-auth.d.ts +26 -0
- package/dist/auth/drive-auth.js +91 -0
- package/dist/auth/drive-setup-cli.d.ts +2 -0
- package/dist/auth/drive-setup-cli.js +157 -0
- package/dist/auth/scopes.d.ts +7 -0
- package/dist/auth/scopes.js +10 -0
- package/dist/drive/tools.d.ts +122 -0
- package/dist/drive/tools.js +281 -0
- package/dist/index.js +23 -9
- package/dist/lib/googleapis-lite.d.ts +2 -0
- package/dist/lib/googleapis-lite.js +3 -0
- package/dist/registers/drive.d.ts +2 -0
- package/dist/registers/drive.js +108 -0
- package/dist/registers/video.js +4 -1
- package/dist/server.js +2 -0
- package/dist/video/youtube-publish.d.ts +14 -0
- package/dist/video/youtube-publish.js +6 -0
- package/dist/youtube/tools.d.ts +2 -0
- package/dist/youtube/tools.js +2 -0
- package/package.json +2 -1
- package/tool-manifest.json +37 -3
package/README.md
CHANGED
|
@@ -128,7 +128,7 @@ export ANTHROPIC_API_KEY=sk-ant-...
|
|
|
128
128
|
---
|
|
129
129
|
|
|
130
130
|
<!-- generated:readme-tools-heading:start — edit scripts/docs-spec.mjs, then npm run plugin:sync -->
|
|
131
|
-
## 제공 도구 (150+ 개 ·
|
|
131
|
+
## 제공 도구 (150+ 개 · 24개 영역)
|
|
132
132
|
<!-- generated:readme-tools-heading:end -->
|
|
133
133
|
|
|
134
134
|
<!-- generated:readme-tools-table:start — edit scripts/docs-spec.mjs, then npm run plugin:sync -->
|
|
@@ -147,6 +147,7 @@ export ANTHROPIC_API_KEY=sk-ant-...
|
|
|
147
147
|
| Facebook | 6 | `facebook_post_photo` / `facebook_post_multi_photo` / `facebook_list_pages` |
|
|
148
148
|
| Google Cloud IAM | 5 | `iam_create_service_account` / `iam_create_key` / `iam_add_iam_policy_binding` |
|
|
149
149
|
| BigQuery | 5 | `bigquery_run_query` / `bigquery_list_datasets` / `bigquery_get_table_schema` |
|
|
150
|
+
| Google Drive | 8 | `drive_upload_file` / `drive_update_file_content` / `drive_create_folder` / `drive_list_files` |
|
|
150
151
|
| GCP Billing | 4 | `gcp_get_billing_info` / `gcp_list_billing_projects` / `gcp_list_budgets` / `gcp_create_budget` |
|
|
151
152
|
| Threads | 7 | `threads_post` / `threads_post_video` / `threads_post_carousel` / `threads_refresh_token` |
|
|
152
153
|
| TikTok Business | 7 | `tiktok_business_plan_video_post` / `tiktok_business_publish_video` / `tiktok_business_get_publish_status` |
|
package/assets/agent-guide.md
CHANGED
|
@@ -73,6 +73,7 @@ row for the job; batching two rows in one `select:` call is fine.
|
|
|
73
73
|
| Remote Config usage + experiments | `select:firebase_get_remote_config_overview,gcp_get_billing_info` |
|
|
74
74
|
| Analytics wiring (Firebase ↔ GA4 ↔ BigQuery) | `select:firebase_link_analytics,firebase_get_analytics_details,ga4_list_account_summaries,ga4_list_properties,ga4_create_property,ga4_list_data_streams,ga4_create_data_stream,ga4_plan_bigquery_link,ga4_create_bigquery_link,ga4_run_report` |
|
|
75
75
|
| BigQuery | `select:bigquery_auth_status,bigquery_list_datasets,bigquery_list_tables,bigquery_get_table_schema,bigquery_run_query` |
|
|
76
|
+
| Google Drive (영상·산출물 업로드·교체·정리) | `select:drive_auth_status,drive_list_files,drive_create_folder,drive_upload_file,drive_update_file_content,drive_get_file,drive_update_file_metadata,drive_trash_file` |
|
|
76
77
|
| GCP billing (Blaze 여부 · 비용 범위 · 예산) | `select:gcp_get_billing_info,gcp_list_billing_projects,gcp_list_budgets,gcp_create_budget` |
|
|
77
78
|
| Real revenue (스토어 정산 원장 — sandbox·테스터가 섞이지 않는 유일한 창구) | `select:appstore_get_sales_report,appstore_get_finance_report,playstore_list_financial_reports,playstore_get_financial_report` |
|
|
78
79
|
| App Store weekly growth insight | `select:appstore_get_weekly_insight,appstore_get_sales_report` |
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { JWT } from 'google-auth-library';
|
|
2
|
+
import type { ServiceAccountKey } from './bigquery-auth.js';
|
|
3
|
+
export declare const DRIVE_SA_PATH: string;
|
|
4
|
+
export declare const DRIVE_SA_ENV = "MIMI_SEED_DRIVE_SA_JSON";
|
|
5
|
+
/** 서비스 계정은 공유받은 범위 안에서만 보이므로 전체 drive 스코프를 쓴다. */
|
|
6
|
+
export declare const DRIVE_SA_SCOPES: string[];
|
|
7
|
+
export type DriveAuthSource = 'service-account-env' | 'service-account' | 'user-oauth';
|
|
8
|
+
/** JSON 문자열 → 서비스 계정 키. 형식이 아니면 throw (메시지에 키 본문을 싣지 않는다). */
|
|
9
|
+
export declare function parseDriveServiceAccountJson(json: string): ServiceAccountKey;
|
|
10
|
+
/** 검증 후 ~/.mimi-seed/drive-service-account.json 에 0600 원자적 저장. */
|
|
11
|
+
export declare function saveDriveServiceAccountJson(json: string): ServiceAccountKey;
|
|
12
|
+
/** 저장된 Drive 서비스 계정 키 삭제. 없으면 false. */
|
|
13
|
+
export declare function deleteDriveServiceAccountJson(): boolean;
|
|
14
|
+
export interface DriveServiceAccount {
|
|
15
|
+
key: ServiceAccountKey;
|
|
16
|
+
source: Exclude<DriveAuthSource, 'user-oauth'>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 설정된 Drive 서비스 계정. 환경 변수가 있으면 그것이 이긴다.
|
|
20
|
+
* 환경 변수가 있는데 형식이 틀리면 조용히 파일로 넘어가지 않고 throw — 잘못된 키를 쓰는 줄
|
|
21
|
+
* 모른 채 다른 계정으로 올라가는 일을 막는다.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getDriveServiceAccount(env?: NodeJS.ProcessEnv): DriveServiceAccount | null;
|
|
24
|
+
/** 서비스 계정 키 → Drive 스코프 JWT 클라이언트. */
|
|
25
|
+
export declare function driveJwt(key: ServiceAccountKey): JWT;
|
|
26
|
+
export declare const DRIVE_AUTH_HINT: string;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { newJWT } from '../lib/google-auth-lite.js';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import { writeCredentialFile } from '#core/atomic-write.js';
|
|
6
|
+
/**
|
|
7
|
+
* Google Drive 인증 — 서비스 계정 우선, 없으면 사용자 OAuth(drive.file).
|
|
8
|
+
*
|
|
9
|
+
* 왜 서비스 계정이 우선인가:
|
|
10
|
+
* - OAuth 경로는 비민감 스코프 drive.file 만 쓴다. 이 앱이 만든 파일만 다룰 수 있어서
|
|
11
|
+
* 사용자가 이미 가진 폴더(예: 팀 공유 폴더)에는 올릴 수 없다.
|
|
12
|
+
* - 서비스 계정은 공유받은 폴더·공유 드라이브 안에서 전체 Drive 스코프로 동작하고,
|
|
13
|
+
* 브라우저 로그인이 없어 CI·클라우드 컨테이너에서도 쓸 수 있다.
|
|
14
|
+
*
|
|
15
|
+
* 키 위치(우선순위):
|
|
16
|
+
* 1. 환경 변수 MIMI_SEED_DRIVE_SA_JSON — 키 JSON 본문. 파일을 둘 수 없는 CI·클라우드용.
|
|
17
|
+
* 2. ~/.mimi-seed/drive-service-account.json — mimi-seed-drive-auth 가 검증 후 저장.
|
|
18
|
+
*
|
|
19
|
+
* 키 본문은 절대 로그·도구 출력·에러 메시지에 싣지 않는다.
|
|
20
|
+
*/
|
|
21
|
+
const CONFIG_DIR = path.join(os.homedir(), '.mimi-seed');
|
|
22
|
+
export const DRIVE_SA_PATH = path.join(CONFIG_DIR, 'drive-service-account.json');
|
|
23
|
+
export const DRIVE_SA_ENV = 'MIMI_SEED_DRIVE_SA_JSON';
|
|
24
|
+
/** 서비스 계정은 공유받은 범위 안에서만 보이므로 전체 drive 스코프를 쓴다. */
|
|
25
|
+
export const DRIVE_SA_SCOPES = ['https://www.googleapis.com/auth/drive'];
|
|
26
|
+
/** JSON 문자열 → 서비스 계정 키. 형식이 아니면 throw (메시지에 키 본문을 싣지 않는다). */
|
|
27
|
+
export function parseDriveServiceAccountJson(json) {
|
|
28
|
+
let parsed;
|
|
29
|
+
try {
|
|
30
|
+
parsed = JSON.parse(json);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
throw new Error('JSON 파싱 실패 — 올바른 서비스 계정 키 파일이 아닙니다.');
|
|
34
|
+
}
|
|
35
|
+
if (parsed.type !== 'service_account' || !parsed.client_email || !parsed.private_key) {
|
|
36
|
+
throw new Error('서비스 계정 키 형식이 아닙니다 (type="service_account", client_email, private_key 필요).');
|
|
37
|
+
}
|
|
38
|
+
return parsed;
|
|
39
|
+
}
|
|
40
|
+
/** 검증 후 ~/.mimi-seed/drive-service-account.json 에 0600 원자적 저장. */
|
|
41
|
+
export function saveDriveServiceAccountJson(json) {
|
|
42
|
+
const parsed = parseDriveServiceAccountJson(json);
|
|
43
|
+
writeCredentialFile(DRIVE_SA_PATH, json);
|
|
44
|
+
return parsed;
|
|
45
|
+
}
|
|
46
|
+
/** 저장된 Drive 서비스 계정 키 삭제. 없으면 false. */
|
|
47
|
+
export function deleteDriveServiceAccountJson() {
|
|
48
|
+
if (!fs.existsSync(DRIVE_SA_PATH))
|
|
49
|
+
return false;
|
|
50
|
+
fs.unlinkSync(DRIVE_SA_PATH);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 설정된 Drive 서비스 계정. 환경 변수가 있으면 그것이 이긴다.
|
|
55
|
+
* 환경 변수가 있는데 형식이 틀리면 조용히 파일로 넘어가지 않고 throw — 잘못된 키를 쓰는 줄
|
|
56
|
+
* 모른 채 다른 계정으로 올라가는 일을 막는다.
|
|
57
|
+
*/
|
|
58
|
+
export function getDriveServiceAccount(env = process.env) {
|
|
59
|
+
const fromEnv = env[DRIVE_SA_ENV];
|
|
60
|
+
if (fromEnv && fromEnv.trim()) {
|
|
61
|
+
try {
|
|
62
|
+
return { key: parseDriveServiceAccountJson(fromEnv), source: 'service-account-env' };
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
throw new Error(`${DRIVE_SA_ENV}: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!fs.existsSync(DRIVE_SA_PATH))
|
|
69
|
+
return null;
|
|
70
|
+
try {
|
|
71
|
+
return { key: parseDriveServiceAccountJson(fs.readFileSync(DRIVE_SA_PATH, 'utf-8')), source: 'service-account' };
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** 서비스 계정 키 → Drive 스코프 JWT 클라이언트. */
|
|
78
|
+
export function driveJwt(key) {
|
|
79
|
+
return newJWT({ email: key.client_email, key: key.private_key, scopes: DRIVE_SA_SCOPES });
|
|
80
|
+
}
|
|
81
|
+
export const DRIVE_AUTH_HINT = [
|
|
82
|
+
'❌ Google Drive 인증이 설정되지 않았어.',
|
|
83
|
+
'',
|
|
84
|
+
'방법 1 — Drive 서비스 계정 (권장: 기존 폴더·공유 드라이브, CI·클라우드):',
|
|
85
|
+
' npx -y @yoonion/mimi-seed-mcp mimi-seed-drive-auth',
|
|
86
|
+
` (파일을 둘 수 없는 환경이면 키 JSON 본문을 환경 변수 ${DRIVE_SA_ENV} 에 넣는다)`,
|
|
87
|
+
' 그 다음 대상 폴더(또는 공유 드라이브)를 서비스 계정 이메일과 공유해.',
|
|
88
|
+
'',
|
|
89
|
+
'방법 2 — Google 계정 OAuth (mimi-seed 가 만든 파일·폴더만 다룸):',
|
|
90
|
+
' npx -y @yoonion/mimi-seed-mcp mimi-seed-auth --domains drive',
|
|
91
|
+
].join('\n');
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import readline from 'node:readline';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { DRIVE_SA_ENV, DRIVE_SA_PATH, driveJwt, getDriveServiceAccount, saveDriveServiceAccountJson, } from './drive-auth.js';
|
|
5
|
+
import * as drive from '../drive/tools.js';
|
|
6
|
+
import { resolveLang } from '#core/lang.js';
|
|
7
|
+
// ko 가 원본이고 en 은 `typeof ko` 를 만족해야 한다 — 키를 빠뜨리면 컴파일이 깨진다.
|
|
8
|
+
const ko = {
|
|
9
|
+
title: ' 🤖 Mimi Seed — Google Drive 서비스 계정 연결',
|
|
10
|
+
why1: ' 서비스 계정은 공유받은 기존 폴더와 공유 드라이브에 파일을 올리고 관리할 수 있어.',
|
|
11
|
+
why2: ' (Google 로그인 OAuth 의 drive.file 권한은 mimi-seed 가 만든 파일·폴더만 다룬다)',
|
|
12
|
+
envWins: (env) => ` ℹ️ 환경 변수 ${env} 이 설정돼 있어 — 저장한 파일보다 환경 변수가 우선한다.`,
|
|
13
|
+
already: (email) => ` ✅ 이미 연결됨 (${email})`,
|
|
14
|
+
reconnect: ' 다시 설정할래? (y/N): ',
|
|
15
|
+
needTitle: ' Drive API 를 쓸 수 있는 서비스 계정 키 JSON 이 필요해:',
|
|
16
|
+
step1: ' 1. GCP Console → APIs & Services → Google Drive API 사용 설정',
|
|
17
|
+
step2: ' 2. IAM & Admin → Service Accounts → 서비스 계정 선택(또는 생성) → Keys → Add Key → JSON',
|
|
18
|
+
step3: ' 3. 올릴 대상 폴더(또는 공유 드라이브)를 서비스 계정 이메일과 "편집자"로 공유',
|
|
19
|
+
step3b: ' 서비스 계정에는 자기 저장 용량이 없으니, 공유 드라이브나 공유받은 폴더에 올린다.',
|
|
20
|
+
step4: ' 4. 다운로드한 JSON 파일 경로를 입력해',
|
|
21
|
+
askPath: ' 서비스 계정 JSON 파일 경로: ',
|
|
22
|
+
noFile: (p) => ` ❌ 파일 없음: ${p}`,
|
|
23
|
+
saved: (email, file) => ` ✅ 저장 완료! (${email})\n ${file}`,
|
|
24
|
+
askFolder: ' 접근을 확인할 Drive 폴더 ID (엔터 시 건너뜀): ',
|
|
25
|
+
probing: (id) => ` 🔎 폴더 ${id} 확인 중...`,
|
|
26
|
+
probeOk: (name, n) => ` ✅ 접근 OK — "${name}" (항목 ${n}개 표시)`,
|
|
27
|
+
probeFail: (msg) => ` ⚠️ 접근 실패: ${msg}`,
|
|
28
|
+
nextTitle: ' 이제 Claude Code 또는 Codex에서:',
|
|
29
|
+
nextExample: ' "이 영상을 Drive 의 영상 폴더에 올려줘"',
|
|
30
|
+
usage: ' 사용법: mimi-seed-drive-auth [--file <서비스계정.json>] [--folder <폴더ID>]',
|
|
31
|
+
};
|
|
32
|
+
const en = {
|
|
33
|
+
title: ' 🤖 Mimi Seed — Connect a Google Drive service account',
|
|
34
|
+
why1: ' A service account can upload to and manage existing folders and shared drives shared with it.',
|
|
35
|
+
why2: ' (The Google sign-in OAuth drive.file grant only covers files and folders mimi-seed created)',
|
|
36
|
+
envWins: (env) => ` ℹ️ ${env} is set — the environment variable wins over the saved file.`,
|
|
37
|
+
already: (email) => ` ✅ Already connected (${email})`,
|
|
38
|
+
reconnect: ' Set it up again? (y/N): ',
|
|
39
|
+
needTitle: ' A service-account key JSON with Drive API access is required:',
|
|
40
|
+
step1: ' 1. GCP Console → APIs & Services → enable the Google Drive API',
|
|
41
|
+
step2: ' 2. IAM & Admin → Service Accounts → pick (or create) one → Keys → Add Key → JSON',
|
|
42
|
+
step3: ' 3. Share the target folder (or shared drive) with the service-account email as Editor',
|
|
43
|
+
step3b: ' Service accounts have no storage quota of their own — upload into a shared drive or a shared folder.',
|
|
44
|
+
step4: ' 4. Enter the path to the downloaded JSON file',
|
|
45
|
+
askPath: ' Path to the service-account JSON file: ',
|
|
46
|
+
noFile: (p) => ` ❌ File not found: ${p}`,
|
|
47
|
+
saved: (email, file) => ` ✅ Saved! (${email})\n ${file}`,
|
|
48
|
+
askFolder: ' Drive folder ID to check access (Enter to skip): ',
|
|
49
|
+
probing: (id) => ` 🔎 Checking folder ${id}...`,
|
|
50
|
+
probeOk: (name, n) => ` ✅ Access OK — "${name}" (${n} item(s) listed)`,
|
|
51
|
+
probeFail: (msg) => ` ⚠️ Access failed: ${msg}`,
|
|
52
|
+
nextTitle: ' Now, in Claude Code or Codex:',
|
|
53
|
+
nextExample: ' "Upload this video to the videos folder on Drive"',
|
|
54
|
+
usage: ' Usage: mimi-seed-drive-auth [--file <service-account.json>] [--folder <folderId>]',
|
|
55
|
+
};
|
|
56
|
+
const M = resolveLang() === 'en' ? en : ko;
|
|
57
|
+
function flag(args, name) {
|
|
58
|
+
const eq = args.find((a) => a.startsWith(`--${name}=`));
|
|
59
|
+
if (eq)
|
|
60
|
+
return eq.slice(name.length + 3);
|
|
61
|
+
const i = args.indexOf(`--${name}`);
|
|
62
|
+
return i >= 0 ? args[i + 1] : undefined;
|
|
63
|
+
}
|
|
64
|
+
async function probe(folderId) {
|
|
65
|
+
const sa = getDriveServiceAccount();
|
|
66
|
+
if (!sa)
|
|
67
|
+
return;
|
|
68
|
+
console.log(M.probing(folderId));
|
|
69
|
+
const client = driveJwt(sa.key);
|
|
70
|
+
try {
|
|
71
|
+
const folder = await drive.getFile(client, folderId);
|
|
72
|
+
const { files } = await drive.listFiles(client, { folderId, pageSize: 10 });
|
|
73
|
+
console.log(M.probeOk(folder.name, files.length));
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
console.log(M.probeFail(drive.driveError(e, sa.source, sa.key.client_email).message));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function main() {
|
|
80
|
+
const args = process.argv.slice(2);
|
|
81
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
82
|
+
console.log(M.usage);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const fileArg = flag(args, 'file');
|
|
86
|
+
const folderArg = flag(args, 'folder');
|
|
87
|
+
console.log('');
|
|
88
|
+
console.log(M.title);
|
|
89
|
+
console.log('');
|
|
90
|
+
console.log(M.why1);
|
|
91
|
+
console.log(M.why2);
|
|
92
|
+
console.log('');
|
|
93
|
+
if (process.env[DRIVE_SA_ENV]?.trim())
|
|
94
|
+
console.log(M.envWins(DRIVE_SA_ENV));
|
|
95
|
+
// 비대화형: --file 로 바로 저장 (CI·스크립트).
|
|
96
|
+
if (fileArg) {
|
|
97
|
+
if (!fs.existsSync(fileArg)) {
|
|
98
|
+
console.log(M.noFile(fileArg));
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
const parsed = saveDriveServiceAccountJson(fs.readFileSync(fileArg, 'utf-8'));
|
|
102
|
+
console.log(M.saved(parsed.client_email, DRIVE_SA_PATH));
|
|
103
|
+
if (folderArg)
|
|
104
|
+
await probe(folderArg);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
108
|
+
const ask = (q) => new Promise((r) => rl.question(q, r));
|
|
109
|
+
try {
|
|
110
|
+
let existing = null;
|
|
111
|
+
try {
|
|
112
|
+
existing = getDriveServiceAccount();
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
existing = null;
|
|
116
|
+
}
|
|
117
|
+
if (existing) {
|
|
118
|
+
console.log(M.already(existing.key.client_email));
|
|
119
|
+
if ((await ask(M.reconnect)).toLowerCase() !== 'y') {
|
|
120
|
+
if (folderArg)
|
|
121
|
+
await probe(folderArg);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
console.log(M.needTitle);
|
|
126
|
+
console.log(M.step1);
|
|
127
|
+
console.log(M.step2);
|
|
128
|
+
console.log(M.step3);
|
|
129
|
+
console.log(M.step3b);
|
|
130
|
+
console.log(M.step4);
|
|
131
|
+
console.log('');
|
|
132
|
+
const jsonPath = (await ask(M.askPath)).trim().replace(/^["']|["']$/g, '');
|
|
133
|
+
if (!fs.existsSync(jsonPath)) {
|
|
134
|
+
console.log(M.noFile(jsonPath));
|
|
135
|
+
process.exitCode = 1;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const parsed = saveDriveServiceAccountJson(fs.readFileSync(jsonPath, 'utf-8'));
|
|
139
|
+
console.log('');
|
|
140
|
+
console.log(M.saved(parsed.client_email, DRIVE_SA_PATH));
|
|
141
|
+
console.log('');
|
|
142
|
+
const folderId = folderArg ?? (await ask(M.askFolder)).trim();
|
|
143
|
+
if (folderId)
|
|
144
|
+
await probe(folderId);
|
|
145
|
+
console.log('');
|
|
146
|
+
console.log(M.nextTitle);
|
|
147
|
+
console.log(M.nextExample);
|
|
148
|
+
console.log('');
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
rl.close();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
main().catch((e) => {
|
|
155
|
+
console.error(`\n ❌ ${e instanceof Error ? e.message : String(e)}\n`);
|
|
156
|
+
process.exit(1);
|
|
157
|
+
});
|
package/dist/auth/scopes.d.ts
CHANGED
|
@@ -69,11 +69,18 @@ export declare const AUTH_DOMAINS: {
|
|
|
69
69
|
readonly scopes: readonly ["https://www.googleapis.com/auth/youtube.readonly", "https://www.googleapis.com/auth/yt-analytics.readonly"];
|
|
70
70
|
readonly summary: "youtube_get_channel·youtube_list_videos·youtube_get_analytics_report — 채널·영상·성과 읽기";
|
|
71
71
|
};
|
|
72
|
+
readonly drive: {
|
|
73
|
+
readonly label: "Google Drive (drive.file)";
|
|
74
|
+
readonly scopes: readonly ["https://www.googleapis.com/auth/drive.file"];
|
|
75
|
+
readonly summary: "drive_* — mimi-seed 가 만든 파일·폴더 업로드·갱신·정리 (기존 폴더·공유 드라이브는 Drive 서비스 계정)";
|
|
76
|
+
};
|
|
72
77
|
};
|
|
73
78
|
export type AuthDomainId = keyof typeof AUTH_DOMAINS;
|
|
74
79
|
/** z.enum 등 튜플이 필요한 자리에 쓰는 도메인 id 목록 (선언 순서 유지). */
|
|
75
80
|
export declare const DOMAIN_IDS: [AuthDomainId, ...AuthDomainId[]];
|
|
76
81
|
export declare const CLOUD_PLATFORM_SCOPE: "https://www.googleapis.com/auth/cloud-platform";
|
|
82
|
+
/** Drive OAuth 경로가 pre-flight 하는 스코프. 도메인 정의에서 파생한다(리터럴 중복 금지). */
|
|
83
|
+
export declare const DRIVE_FILE_SCOPE: "https://www.googleapis.com/auth/drive.file";
|
|
77
84
|
/**
|
|
78
85
|
* Play Developer Reporting API(Android vitals 통계) 전용 스코프. androidpublisher 와
|
|
79
86
|
* 별개다 — SA JWT 와 OAuth playstore 도메인 양쪽에 함께 실어야 통계 도구가 동작한다.
|
package/dist/auth/scopes.js
CHANGED
|
@@ -80,10 +80,20 @@ export const AUTH_DOMAINS = {
|
|
|
80
80
|
],
|
|
81
81
|
summary: 'youtube_get_channel·youtube_list_videos·youtube_get_analytics_report — 채널·영상·성과 읽기',
|
|
82
82
|
},
|
|
83
|
+
drive: {
|
|
84
|
+
label: 'Google Drive (drive.file)',
|
|
85
|
+
// drive.file 은 비민감 스코프다 — 이 앱이 만들었거나 사용자가 이 앱으로 연 파일만 다룬다.
|
|
86
|
+
// 기존 폴더·공유 드라이브 전체를 다루려면 Drive 서비스 계정(mimi-seed-drive-auth)을 쓴다.
|
|
87
|
+
// 전체 drive 스코프는 제한(restricted) 스코프라 OAuth 앱 보안 심사가 필요해 여기 넣지 않는다.
|
|
88
|
+
scopes: ['https://www.googleapis.com/auth/drive.file'],
|
|
89
|
+
summary: 'drive_* — mimi-seed 가 만든 파일·폴더 업로드·갱신·정리 (기존 폴더·공유 드라이브는 Drive 서비스 계정)',
|
|
90
|
+
},
|
|
83
91
|
};
|
|
84
92
|
/** z.enum 등 튜플이 필요한 자리에 쓰는 도메인 id 목록 (선언 순서 유지). */
|
|
85
93
|
export const DOMAIN_IDS = Object.keys(AUTH_DOMAINS);
|
|
86
94
|
export const CLOUD_PLATFORM_SCOPE = AUTH_DOMAINS.gcp.scopes[0];
|
|
95
|
+
/** Drive OAuth 경로가 pre-flight 하는 스코프. 도메인 정의에서 파생한다(리터럴 중복 금지). */
|
|
96
|
+
export const DRIVE_FILE_SCOPE = AUTH_DOMAINS.drive.scopes[0];
|
|
87
97
|
/**
|
|
88
98
|
* Play Developer Reporting API(Android vitals 통계) 전용 스코프. androidpublisher 와
|
|
89
99
|
* 별개다 — SA JWT 와 OAuth playstore 도메인 양쪽에 함께 실어야 통계 도구가 동작한다.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { JWT, OAuth2Client } from 'google-auth-library';
|
|
2
|
+
import type { DriveAuthSource } from '../auth/drive-auth.js';
|
|
3
|
+
/**
|
|
4
|
+
* Google Drive v3 래퍼 — 파일·폴더 조회, 업로드, 내용 갱신, 이름 변경·이동, 휴지통.
|
|
5
|
+
*
|
|
6
|
+
* 모든 호출에 supportsAllDrives 를 싣는다. 서비스 계정은 자기 저장 공간이 없어서 실제로는
|
|
7
|
+
* 공유 드라이브 안에서 일하는 경우가 대부분인데, 이 플래그가 빠지면 공유 드라이브 파일이
|
|
8
|
+
* "없는 파일"(404)로 보인다.
|
|
9
|
+
*/
|
|
10
|
+
export type DriveClient = OAuth2Client | JWT;
|
|
11
|
+
export declare const FOLDER_MIME = "application/vnd.google-apps.folder";
|
|
12
|
+
/**
|
|
13
|
+
* Drive 파일·폴더 ID. 영숫자·밑줄·하이픈만 허용한다 — 이 값은 files.list 의 q 문자열 안에
|
|
14
|
+
* 그대로 들어가므로, 따옴표가 섞이면 질의가 다른 뜻이 된다. 'root' 는 내 드라이브 최상위 별칭.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DRIVE_ID_RE: RegExp;
|
|
17
|
+
/** files.list q 문자열 리터럴 이스케이프 (\ 와 ' ). */
|
|
18
|
+
export declare function escapeQueryValue(value: string): string;
|
|
19
|
+
export interface DriveFile {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
mimeType: string;
|
|
23
|
+
isFolder: boolean;
|
|
24
|
+
size: number | null;
|
|
25
|
+
md5Checksum: string | null;
|
|
26
|
+
createdTime: string | null;
|
|
27
|
+
modifiedTime: string | null;
|
|
28
|
+
parents: string[];
|
|
29
|
+
driveId: string | null;
|
|
30
|
+
trashed: boolean;
|
|
31
|
+
webViewLink: string | null;
|
|
32
|
+
description: string | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Drive 에러를 "무엇을 고칠지"가 보이는 메시지로. 서비스 계정과 OAuth(drive.file) 는
|
|
36
|
+
* 같은 404 라도 원인이 달라 안내를 나눈다.
|
|
37
|
+
*/
|
|
38
|
+
export declare function driveError(e: unknown, source?: DriveAuthSource, clientEmail?: string | null): Error;
|
|
39
|
+
export interface ListFilesInput {
|
|
40
|
+
folderId?: string;
|
|
41
|
+
nameContains?: string;
|
|
42
|
+
mimeType?: string;
|
|
43
|
+
includeTrashed?: boolean;
|
|
44
|
+
pageSize?: number;
|
|
45
|
+
pageToken?: string;
|
|
46
|
+
}
|
|
47
|
+
/** files.list 의 q 문자열 조립 (테스트가 이스케이프를 고정한다). */
|
|
48
|
+
export declare function buildListQuery(input: ListFilesInput): string;
|
|
49
|
+
export declare function listFiles(auth: DriveClient, input: ListFilesInput): Promise<{
|
|
50
|
+
files: DriveFile[];
|
|
51
|
+
nextPageToken: string | null;
|
|
52
|
+
}>;
|
|
53
|
+
export declare function getFile(auth: DriveClient, fileId: string): Promise<DriveFile>;
|
|
54
|
+
export interface CreateFolderInput {
|
|
55
|
+
name: string;
|
|
56
|
+
parentId?: string;
|
|
57
|
+
/** 같은 이름의 폴더가 부모 안에 이미 있으면 새로 만들지 않고 그것을 돌려준다 (기본 true). */
|
|
58
|
+
reuseExisting?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export declare function createFolder(auth: DriveClient, input: CreateFolderInput): Promise<{
|
|
61
|
+
status: "exists";
|
|
62
|
+
folder: DriveFile;
|
|
63
|
+
} | {
|
|
64
|
+
status: "created";
|
|
65
|
+
folder: DriveFile;
|
|
66
|
+
}>;
|
|
67
|
+
/** 확장자 → MIME. 모르면 application/octet-stream (Drive 가 Google 문서로 변환하지 않는다). */
|
|
68
|
+
export declare function guessMimeType(filePath: string): string;
|
|
69
|
+
export interface LocalFile {
|
|
70
|
+
path: string;
|
|
71
|
+
size: number;
|
|
72
|
+
mimeType: string;
|
|
73
|
+
}
|
|
74
|
+
/** 업로드할 로컬 파일 점검 — 절대 경로, 일반 파일, 비어 있지 않음. */
|
|
75
|
+
export declare function inspectLocalFile(filePath: string, mimeType?: string): LocalFile;
|
|
76
|
+
/** 로컬 파일 MD5 — 업로드 결과의 md5Checksum 과 비교해 전송 무결성을 확인한다. */
|
|
77
|
+
export declare function md5OfFile(filePath: string): Promise<string>;
|
|
78
|
+
export interface UploadFileInput {
|
|
79
|
+
filePath: string;
|
|
80
|
+
parentId?: string;
|
|
81
|
+
name?: string;
|
|
82
|
+
mimeType?: string;
|
|
83
|
+
/** 같은 폴더에 같은 이름이 있을 때: error(기본) — 덮어쓰기 대신 drive_update_file_content 를 안내, create_new — 하나 더 만든다. */
|
|
84
|
+
onConflict?: 'error' | 'create_new';
|
|
85
|
+
}
|
|
86
|
+
export declare function uploadFile(auth: DriveClient, input: UploadFileInput): Promise<{
|
|
87
|
+
status: "uploaded";
|
|
88
|
+
file: DriveFile;
|
|
89
|
+
local: LocalFile;
|
|
90
|
+
verified: boolean | null;
|
|
91
|
+
}>;
|
|
92
|
+
export interface UpdateContentInput {
|
|
93
|
+
fileId: string;
|
|
94
|
+
filePath: string;
|
|
95
|
+
mimeType?: string;
|
|
96
|
+
}
|
|
97
|
+
/** 기존 파일의 내용을 로컬 파일로 교체 (같은 fileId·링크 유지, Drive 가 이전 버전을 보관). */
|
|
98
|
+
export declare function updateFileContent(auth: DriveClient, input: UpdateContentInput): Promise<{
|
|
99
|
+
status: "updated";
|
|
100
|
+
before: DriveFile;
|
|
101
|
+
after: DriveFile;
|
|
102
|
+
local: LocalFile;
|
|
103
|
+
verified: boolean | null;
|
|
104
|
+
}>;
|
|
105
|
+
export interface UpdateMetadataInput {
|
|
106
|
+
fileId: string;
|
|
107
|
+
name?: string;
|
|
108
|
+
description?: string;
|
|
109
|
+
moveToFolderId?: string;
|
|
110
|
+
}
|
|
111
|
+
/** 이름·설명 변경, 다른 폴더로 이동. 하나 이상 바꿔야 한다. */
|
|
112
|
+
export declare function updateFileMetadata(auth: DriveClient, input: UpdateMetadataInput): Promise<{
|
|
113
|
+
status: "updated";
|
|
114
|
+
before: DriveFile;
|
|
115
|
+
after: DriveFile;
|
|
116
|
+
}>;
|
|
117
|
+
/** 휴지통으로 이동 (30일 안에는 Drive 휴지통에서 되살릴 수 있다). */
|
|
118
|
+
export declare function trashFile(auth: DriveClient, fileId: string): Promise<{
|
|
119
|
+
status: "trashed";
|
|
120
|
+
before: DriveFile;
|
|
121
|
+
after: DriveFile;
|
|
122
|
+
}>;
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { createReadStream, statSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { google } from '../lib/googleapis-lite.js';
|
|
5
|
+
import { mediaUploadOptions } from '../lib/google-timeouts.js';
|
|
6
|
+
import { authReauthMessage, extractHttpStatus, googleErrorDetail, rawMessage, withCause, } from '../lib/google-errors.js';
|
|
7
|
+
export const FOLDER_MIME = 'application/vnd.google-apps.folder';
|
|
8
|
+
const FIELDS = 'id,name,mimeType,size,md5Checksum,createdTime,modifiedTime,parents,driveId,trashed,webViewLink,description';
|
|
9
|
+
/**
|
|
10
|
+
* Drive 파일·폴더 ID. 영숫자·밑줄·하이픈만 허용한다 — 이 값은 files.list 의 q 문자열 안에
|
|
11
|
+
* 그대로 들어가므로, 따옴표가 섞이면 질의가 다른 뜻이 된다. 'root' 는 내 드라이브 최상위 별칭.
|
|
12
|
+
*/
|
|
13
|
+
export const DRIVE_ID_RE = /^(root|[A-Za-z0-9_-]{10,200})$/;
|
|
14
|
+
function assertDriveId(id, what) {
|
|
15
|
+
if (!DRIVE_ID_RE.test(id))
|
|
16
|
+
throw new Error(`${what} 형식이 올바르지 않아: 영숫자·_·- 만 쓰는 Drive ID 여야 해.`);
|
|
17
|
+
}
|
|
18
|
+
/** files.list q 문자열 리터럴 이스케이프 (\ 와 ' ). */
|
|
19
|
+
export function escapeQueryValue(value) {
|
|
20
|
+
return value.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
|
|
21
|
+
}
|
|
22
|
+
function drive(auth) {
|
|
23
|
+
return google.drive({ version: 'v3', auth: auth });
|
|
24
|
+
}
|
|
25
|
+
function toFile(f) {
|
|
26
|
+
return {
|
|
27
|
+
id: f.id ?? '',
|
|
28
|
+
name: f.name ?? '',
|
|
29
|
+
mimeType: f.mimeType ?? '',
|
|
30
|
+
isFolder: f.mimeType === FOLDER_MIME,
|
|
31
|
+
size: f.size != null ? Number(f.size) : null,
|
|
32
|
+
md5Checksum: f.md5Checksum ?? null,
|
|
33
|
+
createdTime: f.createdTime ?? null,
|
|
34
|
+
modifiedTime: f.modifiedTime ?? null,
|
|
35
|
+
parents: f.parents ?? [],
|
|
36
|
+
driveId: f.driveId ?? null,
|
|
37
|
+
trashed: f.trashed === true,
|
|
38
|
+
webViewLink: f.webViewLink ?? null,
|
|
39
|
+
description: f.description ?? null,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Drive 에러를 "무엇을 고칠지"가 보이는 메시지로. 서비스 계정과 OAuth(drive.file) 는
|
|
44
|
+
* 같은 404 라도 원인이 달라 안내를 나눈다.
|
|
45
|
+
*/
|
|
46
|
+
export function driveError(e, source, clientEmail) {
|
|
47
|
+
const text = rawMessage(e);
|
|
48
|
+
const detail = googleErrorDetail(e);
|
|
49
|
+
const status = extractHttpStatus(e);
|
|
50
|
+
const both = `${text} ${detail ?? ''}`;
|
|
51
|
+
const tail = detail && !text.includes(detail) ? `\nGoogle API: ${detail}` : `\nGoogle API: ${text}`;
|
|
52
|
+
const isSa = source === 'service-account' || source === 'service-account-env';
|
|
53
|
+
const reauth = authReauthMessage(both);
|
|
54
|
+
if (reauth && !isSa)
|
|
55
|
+
return withCause(new Error(reauth), e);
|
|
56
|
+
if (/storageQuotaExceeded|do not have storage quota/i.test(both)) {
|
|
57
|
+
return withCause(new Error([
|
|
58
|
+
'❌ 서비스 계정은 자기 저장 공간이 없어서 "내 드라이브"에는 파일을 만들 수 없어.',
|
|
59
|
+
'→ 공유 드라이브 안의 폴더에 올리거나(서비스 계정을 공유 드라이브 멤버로 추가),',
|
|
60
|
+
' 사용자 OAuth(mimi-seed-auth --domains drive)를 써.',
|
|
61
|
+
].join('\n') + tail), e);
|
|
62
|
+
}
|
|
63
|
+
if (status === 404 || /notFound|File not found/i.test(both)) {
|
|
64
|
+
const lines = isSa
|
|
65
|
+
? [
|
|
66
|
+
`❌ 파일·폴더를 찾을 수 없어 — 없거나 서비스 계정${clientEmail ? `(${clientEmail})` : ''}과 공유되지 않았어.`,
|
|
67
|
+
'→ Drive 에서 대상 폴더(또는 공유 드라이브)를 이 서비스 계정 이메일과 공유해 (편집자 이상).',
|
|
68
|
+
]
|
|
69
|
+
: [
|
|
70
|
+
'❌ 파일·폴더를 찾을 수 없어.',
|
|
71
|
+
'→ OAuth(drive.file) 권한은 mimi-seed 가 만든 파일·폴더만 볼 수 있어.',
|
|
72
|
+
' 기존 폴더를 다루려면 Drive 서비스 계정을 써: npx -y @yoonion/mimi-seed-mcp mimi-seed-drive-auth',
|
|
73
|
+
];
|
|
74
|
+
return withCause(new Error(lines.join('\n') + tail), e);
|
|
75
|
+
}
|
|
76
|
+
if (status === 403 || /insufficientFilePermissions|forbidden|permission/i.test(both)) {
|
|
77
|
+
return withCause(new Error([
|
|
78
|
+
'❌ 이 파일·폴더에 쓸 권한이 없어.',
|
|
79
|
+
isSa
|
|
80
|
+
? '→ 폴더 공유 권한을 "편집자"(공유 드라이브는 "콘텐츠 관리자") 이상으로 올려.'
|
|
81
|
+
: '→ 이 Google 계정의 권한을 확인하거나 Drive 서비스 계정을 써.',
|
|
82
|
+
].join('\n') + tail), e);
|
|
83
|
+
}
|
|
84
|
+
return withCause(new Error(`❌ Google Drive 오류: ${text}${detail && !text.includes(detail) ? `\nGoogle API: ${detail}` : ''}`), e);
|
|
85
|
+
}
|
|
86
|
+
/** files.list 의 q 문자열 조립 (테스트가 이스케이프를 고정한다). */
|
|
87
|
+
export function buildListQuery(input) {
|
|
88
|
+
const q = [];
|
|
89
|
+
if (input.folderId) {
|
|
90
|
+
assertDriveId(input.folderId, 'folderId');
|
|
91
|
+
q.push(`'${input.folderId}' in parents`);
|
|
92
|
+
}
|
|
93
|
+
if (input.nameContains)
|
|
94
|
+
q.push(`name contains '${escapeQueryValue(input.nameContains)}'`);
|
|
95
|
+
if (input.mimeType)
|
|
96
|
+
q.push(`mimeType = '${escapeQueryValue(input.mimeType)}'`);
|
|
97
|
+
if (!input.includeTrashed)
|
|
98
|
+
q.push('trashed = false');
|
|
99
|
+
return q.join(' and ');
|
|
100
|
+
}
|
|
101
|
+
export async function listFiles(auth, input) {
|
|
102
|
+
const pageSize = Math.min(Math.max(Math.trunc(input.pageSize ?? 100), 1), 1000);
|
|
103
|
+
const res = await drive(auth).files.list({
|
|
104
|
+
q: buildListQuery(input) || undefined,
|
|
105
|
+
pageSize,
|
|
106
|
+
pageToken: input.pageToken,
|
|
107
|
+
orderBy: 'folder,name',
|
|
108
|
+
fields: `nextPageToken, files(${FIELDS})`,
|
|
109
|
+
supportsAllDrives: true,
|
|
110
|
+
includeItemsFromAllDrives: true,
|
|
111
|
+
corpora: 'allDrives',
|
|
112
|
+
});
|
|
113
|
+
return { files: (res.data.files ?? []).map(toFile), nextPageToken: res.data.nextPageToken ?? null };
|
|
114
|
+
}
|
|
115
|
+
export async function getFile(auth, fileId) {
|
|
116
|
+
assertDriveId(fileId, 'fileId');
|
|
117
|
+
const res = await drive(auth).files.get({ fileId, fields: FIELDS, supportsAllDrives: true });
|
|
118
|
+
return toFile(res.data);
|
|
119
|
+
}
|
|
120
|
+
/** 부모 폴더 안에서 이름이 정확히 같은 항목(휴지통 제외). 폴더만 찾을지 선택. */
|
|
121
|
+
async function findChildByName(auth, parentId, name, kind) {
|
|
122
|
+
const mime = kind === 'folder' ? `mimeType = '${FOLDER_MIME}'` : `mimeType != '${FOLDER_MIME}'`;
|
|
123
|
+
const res = await drive(auth).files.list({
|
|
124
|
+
q: `'${parentId}' in parents and name = '${escapeQueryValue(name)}' and ${mime} and trashed = false`,
|
|
125
|
+
pageSize: 2,
|
|
126
|
+
fields: `files(${FIELDS})`,
|
|
127
|
+
supportsAllDrives: true,
|
|
128
|
+
includeItemsFromAllDrives: true,
|
|
129
|
+
corpora: 'allDrives',
|
|
130
|
+
});
|
|
131
|
+
const hit = res.data.files?.[0];
|
|
132
|
+
return hit ? toFile(hit) : null;
|
|
133
|
+
}
|
|
134
|
+
function cleanName(name, what) {
|
|
135
|
+
const trimmed = name.trim();
|
|
136
|
+
if (!trimmed)
|
|
137
|
+
throw new Error(`${what} 이 비어 있어.`);
|
|
138
|
+
if (trimmed.length > 255)
|
|
139
|
+
throw new Error(`${what} 은 255자 이하여야 해.`);
|
|
140
|
+
return trimmed;
|
|
141
|
+
}
|
|
142
|
+
export async function createFolder(auth, input) {
|
|
143
|
+
const name = cleanName(input.name, '폴더 이름');
|
|
144
|
+
const parentId = input.parentId ?? 'root';
|
|
145
|
+
assertDriveId(parentId, 'parentId');
|
|
146
|
+
if (input.reuseExisting !== false) {
|
|
147
|
+
const existing = await findChildByName(auth, parentId, name, 'folder');
|
|
148
|
+
if (existing)
|
|
149
|
+
return { status: 'exists', folder: existing };
|
|
150
|
+
}
|
|
151
|
+
const res = await drive(auth).files.create({
|
|
152
|
+
requestBody: { name, mimeType: FOLDER_MIME, parents: [parentId] },
|
|
153
|
+
fields: FIELDS,
|
|
154
|
+
supportsAllDrives: true,
|
|
155
|
+
});
|
|
156
|
+
return { status: 'created', folder: toFile(res.data) };
|
|
157
|
+
}
|
|
158
|
+
const MIME_BY_EXT = {
|
|
159
|
+
'.mp4': 'video/mp4', '.m4v': 'video/mp4', '.mov': 'video/quicktime', '.webm': 'video/webm', '.mkv': 'video/x-matroska',
|
|
160
|
+
'.mp3': 'audio/mpeg', '.m4a': 'audio/mp4', '.wav': 'audio/wav', '.ogg': 'audio/ogg',
|
|
161
|
+
'.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.gif': 'image/gif', '.webp': 'image/webp',
|
|
162
|
+
'.svg': 'image/svg+xml', '.pdf': 'application/pdf', '.zip': 'application/zip', '.json': 'application/json',
|
|
163
|
+
'.txt': 'text/plain', '.md': 'text/markdown', '.csv': 'text/csv', '.html': 'text/html',
|
|
164
|
+
'.srt': 'application/x-subrip', '.vtt': 'text/vtt',
|
|
165
|
+
};
|
|
166
|
+
/** 확장자 → MIME. 모르면 application/octet-stream (Drive 가 Google 문서로 변환하지 않는다). */
|
|
167
|
+
export function guessMimeType(filePath) {
|
|
168
|
+
return MIME_BY_EXT[path.extname(filePath).toLowerCase()] ?? 'application/octet-stream';
|
|
169
|
+
}
|
|
170
|
+
/** 업로드할 로컬 파일 점검 — 절대 경로, 일반 파일, 비어 있지 않음. */
|
|
171
|
+
export function inspectLocalFile(filePath, mimeType) {
|
|
172
|
+
if (!path.isAbsolute(filePath))
|
|
173
|
+
throw new Error('filePath 는 절대 경로여야 해.');
|
|
174
|
+
let size;
|
|
175
|
+
try {
|
|
176
|
+
const stat = statSync(filePath);
|
|
177
|
+
if (!stat.isFile())
|
|
178
|
+
throw new Error('not-a-file');
|
|
179
|
+
size = stat.size;
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
if (e instanceof Error && e.message === 'not-a-file')
|
|
183
|
+
throw new Error(`파일이 아니야: ${filePath}`, { cause: e });
|
|
184
|
+
throw new Error(`파일을 읽을 수 없어: ${filePath}`, { cause: e });
|
|
185
|
+
}
|
|
186
|
+
if (size === 0)
|
|
187
|
+
throw new Error(`빈 파일은 올리지 않아: ${filePath}`);
|
|
188
|
+
return { path: filePath, size, mimeType: mimeType ?? guessMimeType(filePath) };
|
|
189
|
+
}
|
|
190
|
+
/** 로컬 파일 MD5 — 업로드 결과의 md5Checksum 과 비교해 전송 무결성을 확인한다. */
|
|
191
|
+
export function md5OfFile(filePath) {
|
|
192
|
+
return new Promise((resolve, reject) => {
|
|
193
|
+
const hash = createHash('md5');
|
|
194
|
+
createReadStream(filePath)
|
|
195
|
+
.on('data', (chunk) => hash.update(chunk))
|
|
196
|
+
.on('error', reject)
|
|
197
|
+
.on('end', () => resolve(hash.digest('hex')));
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
async function verified(local, remote) {
|
|
201
|
+
if (!remote.md5Checksum)
|
|
202
|
+
return null; // Google 문서 형식 등은 체크섬이 없다
|
|
203
|
+
return (await md5OfFile(local.path)) === remote.md5Checksum;
|
|
204
|
+
}
|
|
205
|
+
export async function uploadFile(auth, input) {
|
|
206
|
+
const local = inspectLocalFile(input.filePath, input.mimeType);
|
|
207
|
+
const name = cleanName(input.name ?? path.basename(input.filePath), '파일 이름');
|
|
208
|
+
const parentId = input.parentId ?? 'root';
|
|
209
|
+
assertDriveId(parentId, 'parentId');
|
|
210
|
+
if (input.onConflict !== 'create_new') {
|
|
211
|
+
const existing = await findChildByName(auth, parentId, name, 'file');
|
|
212
|
+
if (existing) {
|
|
213
|
+
throw new Error(`같은 폴더에 "${name}" 이 이미 있어 (fileId ${existing.id}). ` +
|
|
214
|
+
'내용을 바꾸려면 drive_update_file_content, 하나 더 만들려면 onConflict="create_new".');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const res = await drive(auth).files.create({
|
|
218
|
+
requestBody: { name, parents: [parentId] },
|
|
219
|
+
media: { mimeType: local.mimeType, body: createReadStream(local.path) },
|
|
220
|
+
fields: FIELDS,
|
|
221
|
+
supportsAllDrives: true,
|
|
222
|
+
}, mediaUploadOptions());
|
|
223
|
+
const file = toFile(res.data);
|
|
224
|
+
return { status: 'uploaded', file, local, verified: await verified(local, file) };
|
|
225
|
+
}
|
|
226
|
+
/** 기존 파일의 내용을 로컬 파일로 교체 (같은 fileId·링크 유지, Drive 가 이전 버전을 보관). */
|
|
227
|
+
export async function updateFileContent(auth, input) {
|
|
228
|
+
const local = inspectLocalFile(input.filePath, input.mimeType);
|
|
229
|
+
const before = await getFile(auth, input.fileId);
|
|
230
|
+
if (before.isFolder)
|
|
231
|
+
throw new Error('폴더에는 내용을 올릴 수 없어.');
|
|
232
|
+
const res = await drive(auth).files.update({
|
|
233
|
+
fileId: input.fileId,
|
|
234
|
+
media: { mimeType: local.mimeType, body: createReadStream(local.path) },
|
|
235
|
+
fields: FIELDS,
|
|
236
|
+
supportsAllDrives: true,
|
|
237
|
+
}, mediaUploadOptions());
|
|
238
|
+
const after = toFile(res.data);
|
|
239
|
+
return { status: 'updated', before, after, local, verified: await verified(local, after) };
|
|
240
|
+
}
|
|
241
|
+
/** 이름·설명 변경, 다른 폴더로 이동. 하나 이상 바꿔야 한다. */
|
|
242
|
+
export async function updateFileMetadata(auth, input) {
|
|
243
|
+
if (input.name === undefined && input.description === undefined && input.moveToFolderId === undefined) {
|
|
244
|
+
throw new Error('바꿀 항목(name, description, moveToFolderId)이 하나도 없어.');
|
|
245
|
+
}
|
|
246
|
+
const before = await getFile(auth, input.fileId);
|
|
247
|
+
let addParents;
|
|
248
|
+
let removeParents;
|
|
249
|
+
if (input.moveToFolderId !== undefined) {
|
|
250
|
+
assertDriveId(input.moveToFolderId, 'moveToFolderId');
|
|
251
|
+
if (!before.parents.includes(input.moveToFolderId)) {
|
|
252
|
+
addParents = input.moveToFolderId;
|
|
253
|
+
removeParents = before.parents.join(',') || undefined;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const requestBody = {};
|
|
257
|
+
if (input.name !== undefined)
|
|
258
|
+
requestBody.name = cleanName(input.name, '파일 이름');
|
|
259
|
+
if (input.description !== undefined)
|
|
260
|
+
requestBody.description = input.description;
|
|
261
|
+
const res = await drive(auth).files.update({
|
|
262
|
+
fileId: input.fileId,
|
|
263
|
+
requestBody,
|
|
264
|
+
addParents,
|
|
265
|
+
removeParents,
|
|
266
|
+
fields: FIELDS,
|
|
267
|
+
supportsAllDrives: true,
|
|
268
|
+
});
|
|
269
|
+
return { status: 'updated', before, after: toFile(res.data) };
|
|
270
|
+
}
|
|
271
|
+
/** 휴지통으로 이동 (30일 안에는 Drive 휴지통에서 되살릴 수 있다). */
|
|
272
|
+
export async function trashFile(auth, fileId) {
|
|
273
|
+
const before = await getFile(auth, fileId);
|
|
274
|
+
const res = await drive(auth).files.update({
|
|
275
|
+
fileId,
|
|
276
|
+
requestBody: { trashed: true },
|
|
277
|
+
fields: FIELDS,
|
|
278
|
+
supportsAllDrives: true,
|
|
279
|
+
});
|
|
280
|
+
return { status: 'trashed', before, after: toFile(res.data) };
|
|
281
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const SUBCOMMANDS = {
|
|
|
14
14
|
'mimi-seed-playstore-auth': () => import('./auth/playstore-setup-cli.js'),
|
|
15
15
|
'mimi-seed-appstore-auth': () => import('./appstore/setup-cli.js'),
|
|
16
16
|
'mimi-seed-bigquery-auth': () => import('./auth/bigquery-setup-cli.js'),
|
|
17
|
+
'mimi-seed-drive-auth': () => import('./auth/drive-setup-cli.js'),
|
|
17
18
|
'mimi-seed-jenkins-auth': () => import('./jenkins/setup-cli.js'),
|
|
18
19
|
'mimi-seed-googleads-auth': () => import('./googleads/setup-cli.js'),
|
|
19
20
|
'mimi-seed-social-auth': () => import('./social/setup-cli.js'),
|
|
@@ -23,6 +24,13 @@ const SUBCOMMANDS = {
|
|
|
23
24
|
'mimi-seed-ga4': () => import('./ga4/cli.js'),
|
|
24
25
|
'mimi-seed-release-doctor': () => import('./checks/release-doctor-cli.js'),
|
|
25
26
|
};
|
|
27
|
+
const USAGE = [
|
|
28
|
+
'Subcommands:',
|
|
29
|
+
...Object.keys(SUBCOMMANDS).map((k) => ` npx -y @yoonion/mimi-seed-mcp ${k}`),
|
|
30
|
+
'',
|
|
31
|
+
'Or run the MCP server (no args) — normally started by an MCP client such as Claude Code or Codex:',
|
|
32
|
+
' npx -y @yoonion/mimi-seed-mcp',
|
|
33
|
+
].join('\n');
|
|
26
34
|
async function main() {
|
|
27
35
|
const sub = process.argv[2];
|
|
28
36
|
if (sub && SUBCOMMANDS[sub]) {
|
|
@@ -31,18 +39,24 @@ async function main() {
|
|
|
31
39
|
await SUBCOMMANDS[sub]();
|
|
32
40
|
return;
|
|
33
41
|
}
|
|
42
|
+
// 플래그는 서버 기동으로 흘려보내면 stdin 대기로 멈춘 것처럼 보인다 — 바로 답하고 끝낸다.
|
|
43
|
+
if (sub === '--version' || sub === '-v') {
|
|
44
|
+
console.log(version);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (sub === '--help' || sub === '-h') {
|
|
48
|
+
console.log(`mimi-seed-mcp ${version}\n\n${USAGE}`);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
34
51
|
if (sub && !sub.startsWith('-')) {
|
|
35
|
-
console.error(
|
|
36
|
-
`❌ Unknown subcommand: ${sub}`,
|
|
37
|
-
'',
|
|
38
|
-
'Available:',
|
|
39
|
-
...Object.keys(SUBCOMMANDS).map((k) => ` npx -y @yoonion/mimi-seed-mcp ${k}`),
|
|
40
|
-
'',
|
|
41
|
-
'Or run the MCP server (no args):',
|
|
42
|
-
' npx -y @yoonion/mimi-seed-mcp',
|
|
43
|
-
].join('\n'));
|
|
52
|
+
console.error(`❌ Unknown subcommand: ${sub}\n\n${USAGE}`);
|
|
44
53
|
process.exit(2);
|
|
45
54
|
}
|
|
55
|
+
// 사람이 터미널에서 직접 띄운 경우에만 안내한다. stdout 은 MCP 프로토콜 전용이라 stderr 로.
|
|
56
|
+
if (process.stdin.isTTY) {
|
|
57
|
+
console.error(`mimi-seed-mcp ${version}: MCP server running on stdio, waiting for an MCP client. ` +
|
|
58
|
+
'It is not interactive — press Ctrl+C to exit. Run with --help for subcommands.');
|
|
59
|
+
}
|
|
46
60
|
const server = buildServer(version);
|
|
47
61
|
const transport = new StdioServerTransport();
|
|
48
62
|
await server.connect(transport);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { youtube_v3 } from 'googleapis/build/src/apis/youtube/index.js';
|
|
2
|
+
export type { drive_v3 } from 'googleapis/build/src/apis/drive/index.js';
|
|
2
3
|
export type { youtubeAnalytics_v2 } from 'googleapis/build/src/apis/youtubeAnalytics/index.js';
|
|
3
4
|
/**
|
|
4
5
|
* 기존 `google.<api>(...)` 호출부와 100% 동일하게 동작하는 지연 로딩 네임스페이스.
|
|
@@ -21,6 +22,7 @@ export declare const google: {
|
|
|
21
22
|
readonly analyticsadmin: typeof import("googleapis/build/src/apis/analyticsadmin/index.js").analyticsadmin;
|
|
22
23
|
readonly analyticsdata: typeof import("googleapis/build/src/apis/analyticsdata/index.js").analyticsdata;
|
|
23
24
|
readonly androidpublisher: typeof import("googleapis/build/src/apis/androidpublisher/index.js").androidpublisher;
|
|
25
|
+
readonly drive: typeof import("googleapis/build/src/apis/drive/index.js").drive;
|
|
24
26
|
readonly bigquery: typeof import("googleapis/build/src/apis/bigquery/index.js").bigquery;
|
|
25
27
|
readonly billingbudgets: typeof import("googleapis/build/src/apis/billingbudgets/index.js").billingbudgets;
|
|
26
28
|
readonly cloudbilling: typeof import("googleapis/build/src/apis/cloudbilling/index.js").cloudbilling;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { GOOGLE_PROFILE_ID, getStoredTokens } from '../auth/google-auth.js';
|
|
3
|
+
import { DRIVE_FILE_SCOPE } from '../auth/scopes.js';
|
|
4
|
+
import { DRIVE_AUTH_HINT, driveJwt, getDriveServiceAccount } from '../auth/drive-auth.js';
|
|
5
|
+
import { requireAuth } from '../helpers.js';
|
|
6
|
+
import { jsonResult, errorResult } from '../lib/mcp-response.js';
|
|
7
|
+
import * as drive from '../drive/tools.js';
|
|
8
|
+
/**
|
|
9
|
+
* Drive 인증 해석: Drive 서비스 계정(환경 변수 > 파일)이 있으면 그것, 없으면 Google OAuth(drive.file).
|
|
10
|
+
* 서비스 계정은 공유받은 기존 폴더·공유 드라이브를 다룰 수 있고, OAuth drive.file 은
|
|
11
|
+
* mimi-seed 가 만든 파일·폴더만 다룬다.
|
|
12
|
+
*/
|
|
13
|
+
async function resolveDriveAuth(profile) {
|
|
14
|
+
const sa = getDriveServiceAccount();
|
|
15
|
+
if (sa)
|
|
16
|
+
return { client: driveJwt(sa.key), source: sa.source, clientEmail: sa.key.client_email ?? null };
|
|
17
|
+
if (!getStoredTokens(profile))
|
|
18
|
+
throw new Error(DRIVE_AUTH_HINT);
|
|
19
|
+
return { client: await requireAuth(DRIVE_FILE_SCOPE, profile), source: 'user-oauth', clientEmail: null };
|
|
20
|
+
}
|
|
21
|
+
/** 인증 → 호출 → JSON. Drive 오류는 driveError 로 원인별 안내를 붙인다. */
|
|
22
|
+
async function withDrive(profile, run) {
|
|
23
|
+
let auth;
|
|
24
|
+
try {
|
|
25
|
+
auth = await resolveDriveAuth(profile);
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
return errorResult(e instanceof Error ? e.message : String(e));
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
return jsonResult({ authSource: auth.source, ...(await run(auth.client)) });
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
return errorResult(drive.driveError(e, auth.source, auth.clientEmail).message);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const profile = z.string().regex(GOOGLE_PROFILE_ID).optional()
|
|
38
|
+
.describe('Google 로그인 프로필 (OAuth 사용 시). Drive 서비스 계정이 설정돼 있으면 무시된다.');
|
|
39
|
+
const driveId = (what) => z.string().regex(drive.DRIVE_ID_RE).describe(what);
|
|
40
|
+
const absPath = z.string().min(1).describe('올릴 로컬 파일의 절대 경로');
|
|
41
|
+
export function registerDriveTools(server) {
|
|
42
|
+
server.tool('drive_auth_status', '현재 Google Drive 인증 상태 — Drive 서비스 계정(환경 변수/파일) 또는 Google OAuth(drive.file) 중 무엇이 쓰이는지 확인', { profile }, async ({ profile }) => {
|
|
43
|
+
try {
|
|
44
|
+
const sa = getDriveServiceAccount();
|
|
45
|
+
if (sa) {
|
|
46
|
+
return jsonResult({
|
|
47
|
+
authenticated: true,
|
|
48
|
+
source: sa.source,
|
|
49
|
+
clientEmail: sa.key.client_email,
|
|
50
|
+
note: '대상 폴더나 공유 드라이브를 이 이메일과 공유해야 접근할 수 있다.',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
return errorResult(e instanceof Error ? e.message : String(e));
|
|
56
|
+
}
|
|
57
|
+
const granted = getStoredTokens(profile)?.scope?.split(' ') ?? null;
|
|
58
|
+
if (granted?.includes(DRIVE_FILE_SCOPE)) {
|
|
59
|
+
return jsonResult({
|
|
60
|
+
authenticated: true,
|
|
61
|
+
source: 'user-oauth',
|
|
62
|
+
scope: DRIVE_FILE_SCOPE,
|
|
63
|
+
note: 'drive.file 권한은 mimi-seed 가 만든 파일·폴더만 다룬다. 기존 폴더는 Drive 서비스 계정을 쓴다.',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return jsonResult({ authenticated: false, hint: DRIVE_AUTH_HINT });
|
|
67
|
+
});
|
|
68
|
+
server.tool('drive_list_files', 'Google Drive 파일·폴더 목록 조회 — 폴더 ID, 이름 일부, MIME 형식으로 거른다. 공유 드라이브 포함, 기본으로 휴지통 제외.', {
|
|
69
|
+
folderId: driveId('이 폴더 바로 아래만 조회 (폴더 ID 또는 "root")').optional(),
|
|
70
|
+
nameContains: z.string().max(255).optional().describe('이름에 포함된 문자열'),
|
|
71
|
+
mimeType: z.string().max(255).optional().describe('MIME 형식 일치 (폴더는 application/vnd.google-apps.folder)'),
|
|
72
|
+
includeTrashed: z.boolean().optional().describe('휴지통 항목 포함 (기본 false)'),
|
|
73
|
+
pageSize: z.number().int().min(1).max(1000).optional().describe('페이지 크기 (기본 100)'),
|
|
74
|
+
pageToken: z.string().optional().describe('이전 응답의 nextPageToken'),
|
|
75
|
+
profile,
|
|
76
|
+
}, async ({ profile, ...input }) => withDrive(profile, (c) => drive.listFiles(c, input)));
|
|
77
|
+
server.tool('drive_get_file', 'Google Drive 파일·폴더 하나의 메타데이터(이름, MIME, 크기, MD5, 부모, 링크, 수정 시각) 조회', { fileId: driveId('파일 또는 폴더 ID'), profile }, async ({ fileId, profile }) => withDrive(profile, async (c) => ({ file: await drive.getFile(c, fileId) })));
|
|
78
|
+
server.tool('drive_create_folder', 'Google Drive 폴더 생성. 부모 안에 같은 이름의 폴더가 이미 있으면 새로 만들지 않고 그 폴더를 돌려준다(status=exists).', {
|
|
79
|
+
name: z.string().min(1).max(255).describe('폴더 이름'),
|
|
80
|
+
parentId: driveId('부모 폴더 ID (기본 "root" — 내 드라이브 최상위)').optional(),
|
|
81
|
+
reuseExisting: z.boolean().optional().describe('같은 이름 폴더 재사용 (기본 true). false 면 항상 새로 만든다.'),
|
|
82
|
+
profile,
|
|
83
|
+
}, async ({ profile, ...input }) => withDrive(profile, (c) => drive.createFolder(c, input)));
|
|
84
|
+
server.tool('drive_upload_file', '로컬 파일을 Google Drive 폴더에 새 파일로 업로드 (재개 가능 업로드, 완료 후 MD5 대조). ' +
|
|
85
|
+
'같은 폴더에 같은 이름이 있으면 기본으로 거부한다 — 내용 교체는 drive_update_file_content.', {
|
|
86
|
+
filePath: absPath,
|
|
87
|
+
parentId: driveId('올릴 폴더 ID (기본 "root")').optional(),
|
|
88
|
+
name: z.string().min(1).max(255).optional().describe('Drive 에서 쓸 이름 (기본: 로컬 파일 이름)'),
|
|
89
|
+
mimeType: z.string().max(255).optional().describe('MIME 형식 (기본: 확장자로 추정)'),
|
|
90
|
+
onConflict: z.enum(['error', 'create_new']).optional()
|
|
91
|
+
.describe('같은 이름이 있을 때: error(기본) 또는 create_new(하나 더 만든다)'),
|
|
92
|
+
profile,
|
|
93
|
+
}, async ({ profile, ...input }) => withDrive(profile, (c) => drive.uploadFile(c, input)));
|
|
94
|
+
server.tool('drive_update_file_content', '기존 Drive 파일의 내용을 로컬 파일로 교체 — 같은 fileId·공유 링크를 유지하고, Drive 가 이전 버전을 버전 기록에 보관한다. 완료 후 MD5 대조.', {
|
|
95
|
+
fileId: driveId('내용을 바꿀 파일 ID'),
|
|
96
|
+
filePath: absPath,
|
|
97
|
+
mimeType: z.string().max(255).optional().describe('MIME 형식 (기본: 확장자로 추정)'),
|
|
98
|
+
profile,
|
|
99
|
+
}, async ({ profile, ...input }) => withDrive(profile, (c) => drive.updateFileContent(c, input)));
|
|
100
|
+
server.tool('drive_update_file_metadata', 'Drive 파일·폴더의 이름·설명 변경 또는 다른 폴더로 이동. 하나 이상 지정해야 한다.', {
|
|
101
|
+
fileId: driveId('대상 파일 또는 폴더 ID'),
|
|
102
|
+
name: z.string().min(1).max(255).optional().describe('새 이름'),
|
|
103
|
+
description: z.string().max(4000).optional().describe('새 설명'),
|
|
104
|
+
moveToFolderId: driveId('옮겨 갈 폴더 ID').optional(),
|
|
105
|
+
profile,
|
|
106
|
+
}, async ({ profile, ...input }) => withDrive(profile, (c) => drive.updateFileMetadata(c, input)));
|
|
107
|
+
server.tool('drive_trash_file', 'Drive 파일·폴더를 휴지통으로 이동 (영구 삭제 아님 — Drive 휴지통에서 30일 안에 되살릴 수 있다).', { fileId: driveId('휴지통으로 보낼 파일 또는 폴더 ID'), profile }, async ({ fileId, profile }) => withDrive(profile, (c) => drive.trashFile(c, fileId)));
|
|
108
|
+
}
|
package/dist/registers/video.js
CHANGED
|
@@ -18,6 +18,7 @@ export function registerVideoTools(server) {
|
|
|
18
18
|
'로컬 영상 파일을 선택한 Google 로그인 프로필의 채널에 업로드합니다. expectedChannelId를 실제 인증 채널과 대조한 후 전송합니다.',
|
|
19
19
|
'기본 공개 상태는 private이며 public/unlisted는 같은 턴의 명시 승인 후 confirmVisible=true가 필요합니다.',
|
|
20
20
|
'업로드 후 youtube_get_video_status로 처리 완료 여부와 실제 공개 상태를 확인하세요.',
|
|
21
|
+
'Studio 업로드 기본값은 API 업로드에 적용되지 않습니다. 카테고리·제목/설명 언어·실제 음성 언어를 지정하세요. 댓글 검토 필터는 API로 설정하거나 확인할 수 없어 Studio 검증이 필요합니다.',
|
|
21
22
|
'요청이 타임아웃되면 업로드가 뒤늦게 완료될 수 있으므로 YouTube Studio를 먼저 확인하고 중복 재시도하지 마세요.',
|
|
22
23
|
'YouTube OAuth 권한이 없으면 mimi_seed_auth_start(domains=["youtube"])로 증분 연결하세요.',
|
|
23
24
|
].join(' '), {
|
|
@@ -28,6 +29,8 @@ export function registerVideoTools(server) {
|
|
|
28
29
|
description: z.string().max(5_000).optional().describe('영상 설명과 음원 출처/라이선스 표기'),
|
|
29
30
|
tags: z.array(z.string().min(1).max(500)).max(100).optional(),
|
|
30
31
|
categoryId: z.string().regex(/^\d+$/).default('24').describe('YouTube 카테고리 ID'),
|
|
32
|
+
defaultLanguage: z.string().min(2).max(35).optional().describe('제목·설명의 BCP-47 언어 코드 (예: ko, en). 음성 언어와 별개입니다.'),
|
|
33
|
+
defaultAudioLanguage: z.string().min(2).max(35).optional().describe('실제 음성의 BCP-47 언어 코드 (예: ko, en). 무대사는 생략하고 비공개 업로드 후 Studio에서 동영상 언어를 해당 사항 없음으로 저장·확인하세요. 제목으로 추정하지 않습니다.'),
|
|
31
34
|
privacyStatus: z.enum(['private', 'unlisted', 'public']).default('private'),
|
|
32
35
|
madeForKids: z.boolean().default(false),
|
|
33
36
|
containsSyntheticMedia: z.boolean().optional().describe('현실적으로 보이는 AI 생성·변형 콘텐츠 여부를 YouTube에 고지'),
|
|
@@ -38,7 +41,7 @@ export function registerVideoTools(server) {
|
|
|
38
41
|
const auth = await requireAuth(YOUTUBE_SCOPE, input.profile);
|
|
39
42
|
return jsonResult(await uploadYouTubeVideo(auth, input));
|
|
40
43
|
});
|
|
41
|
-
server.tool('youtube_get_video_status', '내 YouTube 영상의
|
|
44
|
+
server.tool('youtube_get_video_status', '내 YouTube 영상의 처리·공개 상태와 실제 반환된 카테고리·제목/설명 언어·음성 언어를 조회합니다. null은 미확인이며 무대사 판정이 아닙니다. 댓글 검토 필터는 Studio에서 별도로 확인해야 합니다.', {
|
|
42
45
|
profile: z.string().regex(GOOGLE_PROFILE_ID).optional().describe('영상 소유 채널의 Google 로그인 프로필'),
|
|
43
46
|
videoId: z.string().min(1).max(64).describe('YouTube video ID'),
|
|
44
47
|
}, async ({ videoId, profile }) => {
|
package/dist/server.js
CHANGED
|
@@ -22,6 +22,7 @@ import { registerAndroidTools } from './registers/android.js';
|
|
|
22
22
|
import { registerVideoTools } from './registers/video.js';
|
|
23
23
|
import { registerYouTubeTools } from './registers/youtube.js';
|
|
24
24
|
import { registerTikTokBusinessTools } from './registers/tiktok.js';
|
|
25
|
+
import { registerDriveTools } from './registers/drive.js';
|
|
25
26
|
import { registerPrompts } from './prompts.js';
|
|
26
27
|
import { registerResources } from './resources.js';
|
|
27
28
|
import { readToolManifest } from './lib/package-root.js';
|
|
@@ -71,6 +72,7 @@ export function buildServer(version, options = {}) {
|
|
|
71
72
|
registerVideoTools(registrar);
|
|
72
73
|
registerYouTubeTools(registrar);
|
|
73
74
|
registerTikTokBusinessTools(registrar);
|
|
75
|
+
registerDriveTools(registrar);
|
|
74
76
|
registerPrompts(server);
|
|
75
77
|
registerResources(server, { manifest, toolsets });
|
|
76
78
|
return server;
|
|
@@ -10,6 +10,8 @@ export interface UploadYouTubeVideoInput {
|
|
|
10
10
|
description?: string;
|
|
11
11
|
tags?: string[];
|
|
12
12
|
categoryId?: string;
|
|
13
|
+
defaultLanguage?: string;
|
|
14
|
+
defaultAudioLanguage?: string;
|
|
13
15
|
privacyStatus?: YouTubePrivacyStatus;
|
|
14
16
|
madeForKids?: boolean;
|
|
15
17
|
containsSyntheticMedia?: boolean;
|
|
@@ -39,6 +41,10 @@ export declare function getYouTubeVideoStatus(auth: OAuth2Client, videoId: strin
|
|
|
39
41
|
title: string | null;
|
|
40
42
|
channelId: string | null;
|
|
41
43
|
channelTitle: string | null;
|
|
44
|
+
categoryId: string | null;
|
|
45
|
+
defaultLanguage: string | null;
|
|
46
|
+
defaultAudioLanguage: string | null;
|
|
47
|
+
commentModerationVerification: "requires_youtube_studio";
|
|
42
48
|
privacyStatus: string | null;
|
|
43
49
|
publishAt: string | null;
|
|
44
50
|
uploadStatus: string | null;
|
|
@@ -67,6 +73,10 @@ export declare function uploadYouTubeVideo(auth: OAuth2Client, input: UploadYouT
|
|
|
67
73
|
title: string | null;
|
|
68
74
|
channelId: string | null;
|
|
69
75
|
channelTitle: string | null;
|
|
76
|
+
categoryId: string | null;
|
|
77
|
+
defaultLanguage: string | null;
|
|
78
|
+
defaultAudioLanguage: string | null;
|
|
79
|
+
commentModerationVerification: "requires_youtube_studio";
|
|
70
80
|
privacyStatus: string | null;
|
|
71
81
|
publishAt: string | null;
|
|
72
82
|
uploadStatus: string | null;
|
|
@@ -82,6 +92,10 @@ export declare function updateYouTubeVideoPrivacy(auth: OAuth2Client, input: Upd
|
|
|
82
92
|
title: string | null;
|
|
83
93
|
channelId: string | null;
|
|
84
94
|
channelTitle: string | null;
|
|
95
|
+
categoryId: string | null;
|
|
96
|
+
defaultLanguage: string | null;
|
|
97
|
+
defaultAudioLanguage: string | null;
|
|
98
|
+
commentModerationVerification: "requires_youtube_studio";
|
|
85
99
|
privacyStatus: string | null;
|
|
86
100
|
publishAt: string | null;
|
|
87
101
|
uploadStatus: string | null;
|
|
@@ -62,6 +62,10 @@ function safeStatus(video) {
|
|
|
62
62
|
title: video.snippet?.title ?? null,
|
|
63
63
|
channelId: video.snippet?.channelId ?? null,
|
|
64
64
|
channelTitle: video.snippet?.channelTitle ?? null,
|
|
65
|
+
categoryId: video.snippet?.categoryId ?? null,
|
|
66
|
+
defaultLanguage: video.snippet?.defaultLanguage ?? null,
|
|
67
|
+
defaultAudioLanguage: video.snippet?.defaultAudioLanguage ?? null,
|
|
68
|
+
commentModerationVerification: 'requires_youtube_studio',
|
|
65
69
|
privacyStatus: video.status?.privacyStatus ?? null,
|
|
66
70
|
publishAt: video.status?.publishAt ?? null,
|
|
67
71
|
uploadStatus: video.status?.uploadStatus ?? null,
|
|
@@ -121,6 +125,8 @@ export async function uploadYouTubeVideo(auth, input) {
|
|
|
121
125
|
description: input.description ?? '',
|
|
122
126
|
tags: input.tags ?? [],
|
|
123
127
|
categoryId: input.categoryId ?? '24',
|
|
128
|
+
...(input.defaultLanguage ? { defaultLanguage: input.defaultLanguage } : {}),
|
|
129
|
+
...(input.defaultAudioLanguage ? { defaultAudioLanguage: input.defaultAudioLanguage } : {}),
|
|
124
130
|
},
|
|
125
131
|
status: {
|
|
126
132
|
privacyStatus,
|
package/dist/youtube/tools.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare function updateYouTubeVideoMetadata(auth: OAuth2Client, input: Up
|
|
|
22
22
|
tags: string[];
|
|
23
23
|
categoryId: string;
|
|
24
24
|
defaultLanguage: string | null;
|
|
25
|
+
defaultAudioLanguage: string | null;
|
|
25
26
|
};
|
|
26
27
|
after: youtube_v3.Schema$VideoSnippet;
|
|
27
28
|
status: "preview";
|
|
@@ -42,6 +43,7 @@ export declare function updateYouTubeVideoMetadata(auth: OAuth2Client, input: Up
|
|
|
42
43
|
tags: string[];
|
|
43
44
|
categoryId: string;
|
|
44
45
|
defaultLanguage: string | null;
|
|
46
|
+
defaultAudioLanguage: string | null;
|
|
45
47
|
};
|
|
46
48
|
after: youtube_v3.Schema$VideoSnippet;
|
|
47
49
|
status: "updated";
|
package/dist/youtube/tools.js
CHANGED
|
@@ -51,11 +51,13 @@ export async function updateYouTubeVideoMetadata(auth, input) {
|
|
|
51
51
|
const snippet = {
|
|
52
52
|
title, description, categoryId: old.categoryId, tags,
|
|
53
53
|
...(old.defaultLanguage ? { defaultLanguage: old.defaultLanguage } : {}),
|
|
54
|
+
...(old.defaultAudioLanguage ? { defaultAudioLanguage: old.defaultAudioLanguage } : {}),
|
|
54
55
|
};
|
|
55
56
|
const preview = {
|
|
56
57
|
videoId: input.videoId, channel, before: {
|
|
57
58
|
title: old.title, description: old.description ?? '', tags: old.tags ?? [],
|
|
58
59
|
categoryId: old.categoryId, defaultLanguage: old.defaultLanguage ?? null,
|
|
60
|
+
defaultAudioLanguage: old.defaultAudioLanguage ?? null,
|
|
59
61
|
}, after: snippet,
|
|
60
62
|
};
|
|
61
63
|
if (input.confirm !== true)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yoonion/mimi-seed-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Mimi Seed MCP server — Firebase + AdMob + Google Play + App Store management for Claude Code / Codex / Cursor / any MCP client.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"imports": {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"mimi-seed-appstore-auth": "dist/appstore/setup-cli.js",
|
|
13
13
|
"mimi-seed-playstore-auth": "dist/auth/playstore-setup-cli.js",
|
|
14
14
|
"mimi-seed-bigquery-auth": "dist/auth/bigquery-setup-cli.js",
|
|
15
|
+
"mimi-seed-drive-auth": "dist/auth/drive-setup-cli.js",
|
|
15
16
|
"mimi-seed-jenkins-auth": "dist/jenkins/setup-cli.js",
|
|
16
17
|
"mimi-seed-googleads-auth": "dist/googleads/setup-cli.js",
|
|
17
18
|
"mimi-seed-social-auth": "dist/social/setup-cli.js",
|
package/tool-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$comment": "등록된 MCP 도구 + 도메인 메타데이터(label·credential·summary) + 도구 분류(write·destructive·local·idempotent → MCP annotations·confirm 가드) + toolset 그룹·폐기 별칭의 SSOT (src/lib/tool-registrar.ts 가 읽는다). src/__tests__/tool-manifest.test.ts 가 실제 서버 등록 목록과 diff 하고 메타데이터 정합성을 검사한다. 도구 추가/삭제/개명 시 이 파일을 함께 갱신할 것 — 산문 문서에는 정확한 개수를 쓰지 말고 이 파일을 가리킬 것. mimi-seed://tools/catalog 리소스가 이 파일을 그대로 서빙한다.",
|
|
3
|
-
"total":
|
|
3
|
+
"total": 255,
|
|
4
4
|
"alwaysOn": [
|
|
5
5
|
"auth",
|
|
6
6
|
"checks"
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"bigquery",
|
|
35
35
|
"ga4",
|
|
36
36
|
"gsc",
|
|
37
|
-
"googleads"
|
|
37
|
+
"googleads",
|
|
38
|
+
"drive"
|
|
38
39
|
],
|
|
39
40
|
"social": [
|
|
40
41
|
"facebook",
|
|
@@ -45,7 +46,8 @@
|
|
|
45
46
|
],
|
|
46
47
|
"media": [
|
|
47
48
|
"video",
|
|
48
|
-
"youtube"
|
|
49
|
+
"youtube",
|
|
50
|
+
"drive"
|
|
49
51
|
],
|
|
50
52
|
"build": [
|
|
51
53
|
"ci",
|
|
@@ -848,6 +850,38 @@
|
|
|
848
850
|
"youtube_set_thumbnail",
|
|
849
851
|
"youtube_schedule_video"
|
|
850
852
|
]
|
|
853
|
+
},
|
|
854
|
+
"drive": {
|
|
855
|
+
"label": "Google Drive",
|
|
856
|
+
"credential": "Drive 서비스 계정 (또는 Google OAuth drive.file)",
|
|
857
|
+
"summary": "폴더 생성·파일 업로드·내용 교체·이름 변경/이동·휴지통·목록 조회",
|
|
858
|
+
"tools": [
|
|
859
|
+
"drive_auth_status",
|
|
860
|
+
"drive_list_files",
|
|
861
|
+
"drive_get_file",
|
|
862
|
+
"drive_create_folder",
|
|
863
|
+
"drive_upload_file",
|
|
864
|
+
"drive_update_file_content",
|
|
865
|
+
"drive_update_file_metadata",
|
|
866
|
+
"drive_trash_file"
|
|
867
|
+
],
|
|
868
|
+
"write": [
|
|
869
|
+
"drive_create_folder",
|
|
870
|
+
"drive_upload_file",
|
|
871
|
+
"drive_update_file_metadata"
|
|
872
|
+
],
|
|
873
|
+
"destructive": [
|
|
874
|
+
"drive_update_file_content",
|
|
875
|
+
"drive_trash_file"
|
|
876
|
+
],
|
|
877
|
+
"ownGate": [],
|
|
878
|
+
"local": [
|
|
879
|
+
"drive_auth_status"
|
|
880
|
+
],
|
|
881
|
+
"idempotent": [
|
|
882
|
+
"drive_create_folder",
|
|
883
|
+
"drive_update_file_metadata"
|
|
884
|
+
]
|
|
851
885
|
}
|
|
852
886
|
}
|
|
853
887
|
}
|