@yoonion/mimi-seed-mcp 0.23.3 → 0.24.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/assets/agent-guide.md +13 -0
- package/dist/auth/google-auth.d.ts +1 -1
- package/dist/auth/google-auth.js +14 -8
- package/dist/auth/scopes.d.ts +8 -0
- package/dist/auth/scopes.js +16 -4
- package/dist/checks/appstore-submission.d.ts +4 -4
- package/dist/checks/plan.d.ts +2 -2
- package/dist/checks/release-readiness.d.ts +5 -5
- package/dist/checks/risks.d.ts +1 -1
- package/dist/ga4/cli.js +49 -17
- package/dist/ga4/tools.d.ts +7 -2
- package/dist/ga4/tools.js +39 -22
- package/dist/gsc/tools.d.ts +116 -9
- package/dist/gsc/tools.js +93 -17
- package/dist/helpers.d.ts +2 -1
- package/dist/helpers.js +24 -21
- package/dist/index.js +6 -2
- package/dist/lib/cli-args.d.ts +1 -1
- package/dist/lib/cli-args.js +10 -2
- package/dist/lib/tool-menu.d.ts +19 -0
- package/dist/lib/tool-menu.js +61 -0
- package/dist/lib/toolsets.d.ts +4 -2
- package/dist/lib/toolsets.js +26 -4
- package/dist/prompts.d.ts +2 -1
- package/dist/prompts.js +20 -9
- package/dist/registers/ga4.js +30 -37
- package/dist/registers/gsc.js +40 -39
- package/dist/resources.js +22 -3
- package/dist/server.js +2 -1
- package/dist/tools-cli.d.ts +2 -0
- package/dist/tools-cli.js +59 -0
- package/dist/video/schemas.d.ts +3 -3
- package/package.json +2 -1
package/dist/gsc/tools.d.ts
CHANGED
|
@@ -1,23 +1,129 @@
|
|
|
1
1
|
import type { OAuth2Client } from 'google-auth-library';
|
|
2
|
+
import type { searchconsole_v1 } from '@googleapis/searchconsole';
|
|
2
3
|
export type GscAuth = OAuth2Client;
|
|
3
|
-
export declare function listSites(auth: GscAuth): Promise<
|
|
4
|
-
export declare function listSitemaps(auth: GscAuth, siteUrl: string, sitemapIndex?: string): Promise<
|
|
5
|
-
|
|
4
|
+
export declare function listSites(auth: GscAuth): Promise<searchconsole_v1.Schema$WmxSite[]>;
|
|
5
|
+
export declare function listSitemaps(auth: GscAuth, siteUrl: string, sitemapIndex?: string): Promise<(searchconsole_v1.Schema$WmxSitemap | {
|
|
6
|
+
contents: {
|
|
7
|
+
submitted?: string | null;
|
|
8
|
+
type?: string | null;
|
|
9
|
+
}[];
|
|
10
|
+
errors?: string | null;
|
|
11
|
+
isPending?: boolean | null;
|
|
12
|
+
isSitemapsIndex?: boolean | null;
|
|
13
|
+
lastDownloaded?: string | null;
|
|
14
|
+
lastSubmitted?: string | null;
|
|
15
|
+
path?: string | null;
|
|
16
|
+
type?: string | null;
|
|
17
|
+
warnings?: string | null;
|
|
18
|
+
})[]>;
|
|
19
|
+
export declare function getSitemap(auth: GscAuth, siteUrl: string, feedpath: string): Promise<searchconsole_v1.Schema$WmxSitemap | {
|
|
20
|
+
contents: {
|
|
21
|
+
submitted?: string | null;
|
|
22
|
+
type?: string | null;
|
|
23
|
+
}[];
|
|
24
|
+
errors?: string | null;
|
|
25
|
+
isPending?: boolean | null;
|
|
26
|
+
isSitemapsIndex?: boolean | null;
|
|
27
|
+
lastDownloaded?: string | null;
|
|
28
|
+
lastSubmitted?: string | null;
|
|
29
|
+
path?: string | null;
|
|
30
|
+
type?: string | null;
|
|
31
|
+
warnings?: string | null;
|
|
32
|
+
}>;
|
|
6
33
|
/** 사이트맵 제출 — webmasters(read-write) 스코프 필요. 응답 본문은 없음(204). */
|
|
7
34
|
export declare function submitSitemap(auth: GscAuth, siteUrl: string, feedpath: string): Promise<{
|
|
8
35
|
submitted: string;
|
|
9
36
|
siteUrl: string;
|
|
10
37
|
}>;
|
|
11
|
-
export declare function inspectUrl(auth: GscAuth, siteUrl: string, inspectionUrl: string, languageCode?: string): Promise<
|
|
12
|
-
export
|
|
38
|
+
export declare function inspectUrl(auth: GscAuth, siteUrl: string, inspectionUrl: string, languageCode?: string): Promise<searchconsole_v1.Schema$UrlInspectionResult>;
|
|
39
|
+
export declare const SEARCH_TYPES: readonly ["web", "image", "video", "news", "discover", "googleNews"];
|
|
40
|
+
export declare const SEARCH_FILTER_DIMENSIONS: readonly ["page", "query", "country", "device", "searchAppearance", "brandedClassification"];
|
|
41
|
+
export declare const SEARCH_FILTER_OPERATORS: readonly ["equals", "notEquals", "contains", "notContains", "includingRegex", "excludingRegex"];
|
|
42
|
+
interface SearchAnalyticsFilter {
|
|
43
|
+
dimension: (typeof SEARCH_FILTER_DIMENSIONS)[number];
|
|
44
|
+
operator?: (typeof SEARCH_FILTER_OPERATORS)[number];
|
|
45
|
+
expression: string;
|
|
46
|
+
}
|
|
47
|
+
interface SearchAnalyticsParams {
|
|
13
48
|
startDate: string;
|
|
14
49
|
endDate: string;
|
|
15
|
-
dimensions?: string
|
|
50
|
+
dimensions?: string;
|
|
16
51
|
rowLimit?: number;
|
|
17
52
|
startRow?: number;
|
|
18
|
-
type?:
|
|
53
|
+
type?: (typeof SEARCH_TYPES)[number];
|
|
54
|
+
filters?: SearchAnalyticsFilter[];
|
|
55
|
+
summaryOnly?: boolean;
|
|
56
|
+
includeTotals?: boolean;
|
|
19
57
|
}
|
|
20
|
-
export declare function searchAnalytics(auth: GscAuth, siteUrl: string, params: SearchAnalyticsParams): Promise<
|
|
58
|
+
export declare function searchAnalytics(auth: GscAuth, siteUrl: string, params: SearchAnalyticsParams): Promise<{
|
|
59
|
+
aggregationType: string | null;
|
|
60
|
+
rowSummary: {
|
|
61
|
+
rowCount: number;
|
|
62
|
+
totalClicks: number;
|
|
63
|
+
totalImpressions: number;
|
|
64
|
+
avgCtr: number;
|
|
65
|
+
avgPosition: number | null;
|
|
66
|
+
};
|
|
67
|
+
pagination: {
|
|
68
|
+
startRow: number;
|
|
69
|
+
rowLimit: number;
|
|
70
|
+
nextStartRow: number | null;
|
|
71
|
+
mayOmitRows: boolean;
|
|
72
|
+
};
|
|
73
|
+
rows: searchconsole_v1.Schema$ApiDataRow[];
|
|
74
|
+
period: {
|
|
75
|
+
startDate: string;
|
|
76
|
+
endDate: string;
|
|
77
|
+
};
|
|
78
|
+
type: "web" | "video" | "image" | "news" | "discover" | "googleNews";
|
|
79
|
+
dimensions: string[];
|
|
80
|
+
} | {
|
|
81
|
+
rows?: searchconsole_v1.Schema$ApiDataRow[] | undefined;
|
|
82
|
+
aggregationType: string | null;
|
|
83
|
+
summary: {
|
|
84
|
+
rowCount: number;
|
|
85
|
+
totalClicks: number;
|
|
86
|
+
totalImpressions: number;
|
|
87
|
+
avgCtr: number;
|
|
88
|
+
avgPosition: number | null;
|
|
89
|
+
};
|
|
90
|
+
period: {
|
|
91
|
+
startDate: string;
|
|
92
|
+
endDate: string;
|
|
93
|
+
};
|
|
94
|
+
type: "web" | "video" | "image" | "news" | "discover" | "googleNews";
|
|
95
|
+
dimensions: string[];
|
|
96
|
+
} | {
|
|
97
|
+
summary: {
|
|
98
|
+
rowCount: number;
|
|
99
|
+
totalClicks: number;
|
|
100
|
+
totalImpressions: number;
|
|
101
|
+
avgCtr: number;
|
|
102
|
+
avgPosition: number | null;
|
|
103
|
+
};
|
|
104
|
+
totalAggregationType: string | null;
|
|
105
|
+
aggregationType: string | null;
|
|
106
|
+
rowSummary: {
|
|
107
|
+
rowCount: number;
|
|
108
|
+
totalClicks: number;
|
|
109
|
+
totalImpressions: number;
|
|
110
|
+
avgCtr: number;
|
|
111
|
+
avgPosition: number | null;
|
|
112
|
+
};
|
|
113
|
+
pagination: {
|
|
114
|
+
startRow: number;
|
|
115
|
+
rowLimit: number;
|
|
116
|
+
nextStartRow: number | null;
|
|
117
|
+
mayOmitRows: boolean;
|
|
118
|
+
};
|
|
119
|
+
rows: searchconsole_v1.Schema$ApiDataRow[];
|
|
120
|
+
period: {
|
|
121
|
+
startDate: string;
|
|
122
|
+
endDate: string;
|
|
123
|
+
};
|
|
124
|
+
type: "web" | "video" | "image" | "news" | "discover" | "googleNews";
|
|
125
|
+
dimensions: string[];
|
|
126
|
+
}>;
|
|
21
127
|
export interface SearchAnalyticsRow {
|
|
22
128
|
keys?: string[] | null;
|
|
23
129
|
clicks?: number | null;
|
|
@@ -35,5 +141,6 @@ export declare function summarizeRows(rows: SearchAnalyticsRow[]): {
|
|
|
35
141
|
totalClicks: number;
|
|
36
142
|
totalImpressions: number;
|
|
37
143
|
avgCtr: number;
|
|
38
|
-
avgPosition: number;
|
|
144
|
+
avgPosition: number | null;
|
|
39
145
|
};
|
|
146
|
+
export {};
|
package/dist/gsc/tools.js
CHANGED
|
@@ -5,7 +5,7 @@ import { notDotSegment } from '../lib/resource-id.js';
|
|
|
5
5
|
*
|
|
6
6
|
* `searchconsole('v1')` 은 구 `webmasters('v3')` 의 후속으로, sites/sitemaps/
|
|
7
7
|
* searchanalytics 에 더해 URL Inspection(`urlInspection.index.inspect`)을 포함한다.
|
|
8
|
-
*
|
|
8
|
+
* 조회에는 webmasters.readonly 또는 webmasters, 사이트맵 제출에는 webmasters를 사용한다.
|
|
9
9
|
*/
|
|
10
10
|
const sc = () => google.searchconsole('v1');
|
|
11
11
|
// ─── 속성(사이트) 목록 ───
|
|
@@ -14,15 +14,20 @@ export async function listSites(auth) {
|
|
|
14
14
|
return res.data.siteEntry ?? [];
|
|
15
15
|
}
|
|
16
16
|
// ─── 사이트맵 ───
|
|
17
|
+
function withoutIndexedCount(sitemap) {
|
|
18
|
+
if (!sitemap.contents)
|
|
19
|
+
return sitemap;
|
|
20
|
+
return { ...sitemap, contents: sitemap.contents.map(({ indexed: _indexed, ...content }) => content) };
|
|
21
|
+
}
|
|
17
22
|
export async function listSitemaps(auth, siteUrl, sitemapIndex) {
|
|
18
23
|
const res = await sc().sitemaps.list({ auth, siteUrl: notDotSegment(siteUrl, 'siteUrl'), sitemapIndex });
|
|
19
|
-
return res.data.sitemap ?? [];
|
|
24
|
+
return (res.data.sitemap ?? []).map(withoutIndexedCount);
|
|
20
25
|
}
|
|
21
26
|
export async function getSitemap(auth, siteUrl, feedpath) {
|
|
22
27
|
const res = await sc().sitemaps.get({
|
|
23
28
|
auth, siteUrl: notDotSegment(siteUrl, 'siteUrl'), feedpath: notDotSegment(feedpath, 'feedpath'),
|
|
24
29
|
});
|
|
25
|
-
return res.data;
|
|
30
|
+
return withoutIndexedCount(res.data);
|
|
26
31
|
}
|
|
27
32
|
/** 사이트맵 제출 — webmasters(read-write) 스코프 필요. 응답 본문은 없음(204). */
|
|
28
33
|
export async function submitSitemap(auth, siteUrl, feedpath) {
|
|
@@ -39,20 +44,79 @@ export async function inspectUrl(auth, siteUrl, inspectionUrl, languageCode = 'e
|
|
|
39
44
|
});
|
|
40
45
|
return res.data.inspectionResult ?? {};
|
|
41
46
|
}
|
|
42
|
-
|
|
47
|
+
// ─── 검색 성과 (Search Analytics) ───
|
|
48
|
+
export const SEARCH_TYPES = ['web', 'image', 'video', 'news', 'discover', 'googleNews'];
|
|
49
|
+
export const SEARCH_FILTER_DIMENSIONS = ['page', 'query', 'country', 'device', 'searchAppearance', 'brandedClassification'];
|
|
50
|
+
export const SEARCH_FILTER_OPERATORS = ['equals', 'notEquals', 'contains', 'notContains', 'includingRegex', 'excludingRegex'];
|
|
51
|
+
async function querySearchAnalytics(auth, siteUrl, requestBody) {
|
|
43
52
|
const res = await sc().searchanalytics.query({
|
|
44
53
|
auth,
|
|
45
|
-
siteUrl
|
|
46
|
-
requestBody
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
siteUrl,
|
|
55
|
+
requestBody,
|
|
56
|
+
});
|
|
57
|
+
const rows = res.data.rows ?? [];
|
|
58
|
+
// Discover and the Google News app/site don't report position. Google can return a zero placeholder.
|
|
59
|
+
const hasPosition = requestBody.type !== 'discover' && requestBody.type !== 'googleNews';
|
|
60
|
+
return {
|
|
61
|
+
rows: hasPosition ? rows : rows.map((row) => ({ ...row, position: null })),
|
|
62
|
+
aggregationType: res.data.responseAggregationType ?? null,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export async function searchAnalytics(auth, siteUrl, params) {
|
|
66
|
+
const { startDate, endDate, startRow = 0, rowLimit = 1000, type = 'web', filters, summaryOnly, includeTotals } = params;
|
|
67
|
+
if (startDate > endDate)
|
|
68
|
+
throw new Error('startDate는 endDate 이전 또는 같은 날짜여야 해.');
|
|
69
|
+
const dimensions = params.dimensions?.split(',').map((value) => value.trim()).filter(Boolean) ?? [];
|
|
70
|
+
const reportDimensions = summaryOnly ? [] : dimensions;
|
|
71
|
+
if (startRow > 0 && reportDimensions.length === 0 && !summaryOnly) {
|
|
72
|
+
throw new Error('startRow는 dimensions로 분해한 조회에만 사용할 수 있어.');
|
|
73
|
+
}
|
|
74
|
+
const property = notDotSegment(siteUrl, 'siteUrl');
|
|
75
|
+
const period = { startDate, endDate };
|
|
76
|
+
const request = {
|
|
77
|
+
...period,
|
|
78
|
+
type,
|
|
79
|
+
dimensionFilterGroups: filters?.length
|
|
80
|
+
? [{ groupType: 'and', filters: filters.map((filter) => ({ ...filter, operator: filter.operator ?? 'equals' })) }]
|
|
81
|
+
: undefined,
|
|
82
|
+
};
|
|
83
|
+
const report = { period, type, dimensions: reportDimensions };
|
|
84
|
+
if (reportDimensions.length === 0) {
|
|
85
|
+
const { rows, aggregationType } = await querySearchAnalytics(auth, property, { ...request, rowLimit: 1 });
|
|
86
|
+
return { ...report, aggregationType, summary: summarizeRows(rows), ...(summaryOnly ? {} : { rows }) };
|
|
87
|
+
}
|
|
88
|
+
const { rows, aggregationType } = await querySearchAnalytics(auth, property, {
|
|
89
|
+
...request, dimensions: reportDimensions, rowLimit, startRow,
|
|
90
|
+
});
|
|
91
|
+
const page = {
|
|
92
|
+
...report,
|
|
93
|
+
aggregationType,
|
|
94
|
+
rowSummary: summarizeRows(rows),
|
|
95
|
+
pagination: {
|
|
96
|
+
startRow,
|
|
97
|
+
rowLimit,
|
|
98
|
+
nextStartRow: rows.length === rowLimit ? startRow + rows.length : null,
|
|
99
|
+
mayOmitRows: true,
|
|
53
100
|
},
|
|
101
|
+
rows,
|
|
102
|
+
};
|
|
103
|
+
if (!includeTotals)
|
|
104
|
+
return page;
|
|
105
|
+
// Google requires automatic aggregation when a page filter is present. With only a
|
|
106
|
+
// page grouping, preserve page aggregation after removing the grouping for totals.
|
|
107
|
+
let totalAggregation;
|
|
108
|
+
if (!filters?.some((filter) => filter.dimension === 'page')) {
|
|
109
|
+
if (aggregationType === 'byPage' || aggregationType === 'byProperty')
|
|
110
|
+
totalAggregation = aggregationType;
|
|
111
|
+
else if (reportDimensions.includes('page'))
|
|
112
|
+
totalAggregation = 'byPage';
|
|
113
|
+
}
|
|
114
|
+
const totals = await querySearchAnalytics(auth, property, {
|
|
115
|
+
...request,
|
|
116
|
+
rowLimit: 1,
|
|
117
|
+
aggregationType: totalAggregation,
|
|
54
118
|
});
|
|
55
|
-
return
|
|
119
|
+
return { ...page, summary: summarizeRows(totals.rows), totalAggregationType: totals.aggregationType };
|
|
56
120
|
}
|
|
57
121
|
/**
|
|
58
122
|
* Search Analytics rows 요약.
|
|
@@ -60,14 +124,26 @@ export async function searchAnalytics(auth, siteUrl, params) {
|
|
|
60
124
|
* 노출이 1인 행과 1000인 행을 동등 취급해 실제 평균 순위를 왜곡한다.
|
|
61
125
|
*/
|
|
62
126
|
export function summarizeRows(rows) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
127
|
+
let totalClicks = 0;
|
|
128
|
+
let totalImpressions = 0;
|
|
129
|
+
let positionImpressions = 0;
|
|
130
|
+
let weightedPosition = 0;
|
|
131
|
+
for (const row of rows) {
|
|
132
|
+
const impressions = row.impressions ?? 0;
|
|
133
|
+
totalClicks += row.clicks ?? 0;
|
|
134
|
+
totalImpressions += impressions;
|
|
135
|
+
if (row.position != null && row.position > 0) {
|
|
136
|
+
positionImpressions += impressions;
|
|
137
|
+
weightedPosition += row.position * impressions;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
66
140
|
return {
|
|
67
141
|
rowCount: rows.length,
|
|
68
142
|
totalClicks,
|
|
69
143
|
totalImpressions,
|
|
70
144
|
avgCtr: totalImpressions > 0 ? Math.round((totalClicks / totalImpressions) * 10000) / 10000 : 0,
|
|
71
|
-
avgPosition: totalImpressions > 0
|
|
145
|
+
avgPosition: totalImpressions > 0 && positionImpressions === totalImpressions
|
|
146
|
+
? Math.round((weightedPosition / totalImpressions) * 100) / 100
|
|
147
|
+
: null,
|
|
72
148
|
};
|
|
73
149
|
}
|
package/dist/helpers.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ export { ensureFreshAccessToken };
|
|
|
7
7
|
*
|
|
8
8
|
* 기존엔 만료 시 각 OAuth 도구(firebase/admob/iam/googleads/checks)가
|
|
9
9
|
* googleapis GaxiosError 를 그대로 노출 → 사용자는 "재로그인하라"는 안내를 못 받았다.
|
|
10
|
+
* 스코프 배열을 넘기면 그중 하나만 부여되어 있어도 통과한다.
|
|
10
11
|
*/
|
|
11
|
-
export declare function requireAuth(requiredScope?: string, profile?: string): Promise<import("google-auth-library").OAuth2Client>;
|
|
12
|
+
export declare function requireAuth(requiredScope?: string | readonly string[], profile?: string): Promise<import("google-auth-library").OAuth2Client>;
|
|
12
13
|
export declare const PLAY_AUTH_HINT: string;
|
|
13
14
|
export declare const APPSTORE_AUTH_HINT: string;
|
|
14
15
|
/**
|
package/dist/helpers.js
CHANGED
|
@@ -4,13 +4,20 @@ import { getServiceAccountClient, getServiceAccountJson } from './auth/playstore
|
|
|
4
4
|
import { getAppStoreCredentials } from './appstore/auth.js';
|
|
5
5
|
export { ensureFreshAccessToken };
|
|
6
6
|
const REAUTH_CMD = ' npx -y @yoonion/mimi-seed-mcp mimi-seed-auth';
|
|
7
|
-
function formatAuthError(p, profile) {
|
|
7
|
+
function formatAuthError(p, profile, scopes = []) {
|
|
8
|
+
// Scope alternatives are ordered by the caller. Recommend the first available domain.
|
|
9
|
+
const domain = scopes.flatMap(domainsForScope)[0];
|
|
10
|
+
const reauthCommand = [
|
|
11
|
+
REAUTH_CMD,
|
|
12
|
+
profile === undefined ? '' : ` --profile ${profile}`,
|
|
13
|
+
domain ? ` --domains ${domain}` : '',
|
|
14
|
+
].join('');
|
|
8
15
|
// 재로그인 안내는 needsReauth 인 경우에만 — CONFIG_FETCH_FAILED 처럼 재로그인이
|
|
9
16
|
// 해법이 아닌 에러에 무조건 붙이면 같은 실패를 반복하게 만든다.
|
|
10
17
|
return [
|
|
11
18
|
`❌ [${p.code}] ${p.message}`,
|
|
12
19
|
p.hint ? `→ ${p.hint}` : '',
|
|
13
|
-
...(p.needsReauth ? ['', '터미널에서 재로그인:',
|
|
20
|
+
...(p.needsReauth ? ['', '터미널에서 재로그인:', reauthCommand] : []),
|
|
14
21
|
]
|
|
15
22
|
.filter((l) => l !== '')
|
|
16
23
|
.join('\n');
|
|
@@ -28,24 +35,19 @@ function formatAuthError(p, profile) {
|
|
|
28
35
|
*
|
|
29
36
|
* OAuth 토큰에만 적용된다 — SA JWT 는 자체 scopes 로 토큰을 받으므로 이 검사 대상이 아니다.
|
|
30
37
|
*/
|
|
31
|
-
function assertStoredScope(
|
|
32
|
-
if (
|
|
38
|
+
function assertStoredScope(scopes, scopeStr, profile) {
|
|
39
|
+
if (scopes.length === 0)
|
|
33
40
|
return;
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
: !scopeStr.split(' ').filter(Boolean).includes(requiredScope);
|
|
37
|
-
if (!missing)
|
|
41
|
+
const grantedScopes = scopeStr?.split(/\s+/);
|
|
42
|
+
if (scopes.some((scope) => grantedScopes ? grantedScopes.includes(scope) : isPreTrackingScope(scope)))
|
|
38
43
|
return;
|
|
39
|
-
const domainArg = domainsForScope(requiredScope).join(',');
|
|
40
44
|
throw new Error(formatAuthError({
|
|
41
45
|
code: 'INSUFFICIENT_SCOPE',
|
|
42
|
-
message: `이 도구는 추가 권한이 필요해 (${
|
|
43
|
-
hint:
|
|
44
|
-
? `mimi-seed-auth${profile === undefined ? '' : ` --profile ${profile}`} --domains ${domainArg} 로 재로그인하면 기존 권한은 유지한 채 이 권한만 추가돼.`
|
|
45
|
-
: 'mimi-seed-auth 로 재로그인하면 새 권한이 부여돼.',
|
|
46
|
+
message: `이 도구는 추가 권한이 필요해 (${scopes.join(' 또는 ')}). 현재 로그인에 그 권한이 없어.`,
|
|
47
|
+
hint: '아래 명령으로 로그인하면 기존 권한을 유지하면서 필요한 권한을 추가할 수 있어.',
|
|
46
48
|
retriable: false,
|
|
47
49
|
needsReauth: true,
|
|
48
|
-
}));
|
|
50
|
+
}, profile, scopes));
|
|
49
51
|
}
|
|
50
52
|
/**
|
|
51
53
|
* OAuth 클라이언트 확보 — 호출 전에 access_token 을 사전 갱신하고,
|
|
@@ -54,13 +56,15 @@ function assertStoredScope(requiredScope, scopeStr, profile) {
|
|
|
54
56
|
*
|
|
55
57
|
* 기존엔 만료 시 각 OAuth 도구(firebase/admob/iam/googleads/checks)가
|
|
56
58
|
* googleapis GaxiosError 를 그대로 노출 → 사용자는 "재로그인하라"는 안내를 못 받았다.
|
|
59
|
+
* 스코프 배열을 넘기면 그중 하나만 부여되어 있어도 통과한다.
|
|
57
60
|
*/
|
|
58
61
|
export async function requireAuth(requiredScope, profile) {
|
|
62
|
+
const scopes = typeof requiredScope === 'string' ? [requiredScope] : requiredScope ?? [];
|
|
59
63
|
const result = await ensureFreshAccessToken(undefined, profile);
|
|
60
64
|
if (result.status === 'unauthenticated' || result.status === 'expired_refresh_failed') {
|
|
61
|
-
throw new Error(formatAuthError(result.error, profile));
|
|
65
|
+
throw new Error(formatAuthError(result.error, profile, scopes));
|
|
62
66
|
}
|
|
63
|
-
const client = getAuthenticatedClient(profile);
|
|
67
|
+
const client = getAuthenticatedClient(profile, result.tokens);
|
|
64
68
|
if (!client) {
|
|
65
69
|
throw new Error(formatAuthError({
|
|
66
70
|
code: 'UNAUTHENTICATED',
|
|
@@ -68,11 +72,10 @@ export async function requireAuth(requiredScope, profile) {
|
|
|
68
72
|
hint: 'mimi-seed-auth 로 로그인하세요.',
|
|
69
73
|
retriable: false,
|
|
70
74
|
needsReauth: true,
|
|
71
|
-
}));
|
|
75
|
+
}, profile, scopes));
|
|
72
76
|
}
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
assertStoredScope(requiredScope, result.tokens.scope, profile);
|
|
77
|
+
// 같은 토큰으로 인증 클라이언트를 만든 뒤 해당 토큰의 스코프를 검사한다.
|
|
78
|
+
assertStoredScope(scopes, result.tokens.scope, profile);
|
|
76
79
|
return client;
|
|
77
80
|
}
|
|
78
81
|
export const PLAY_AUTH_HINT = [
|
|
@@ -119,7 +122,7 @@ export async function requirePlayStoreAuth(packageName, requiredScope) {
|
|
|
119
122
|
throw new Error(PLAY_AUTH_HINT);
|
|
120
123
|
// OAuth 폴백일 때만 스코프 pre-flight — SA JWT 는 자체 scopes 로 토큰을 받으므로
|
|
121
124
|
// (getServiceAccountClient 가 reporting 스코프를 이미 싣는다) 해당 없음.
|
|
122
|
-
assertStoredScope(requiredScope, result.tokens.scope);
|
|
125
|
+
assertStoredScope(requiredScope ? [requiredScope] : [], result.tokens.scope);
|
|
123
126
|
return oauth;
|
|
124
127
|
}
|
|
125
128
|
export function requireServiceAccountJson(packageName) {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
-
import { buildServer } from './server.js';
|
|
4
2
|
import { readPackageRootText } from './lib/package-root.js';
|
|
5
3
|
// npm 패키지 루트의 버전을 단일 출처로 사용.
|
|
6
4
|
// 하드코딩하면 publish 때마다 serverInfo.version 이 드리프트하므로 런타임에 읽는다.
|
|
@@ -22,6 +20,7 @@ const SUBCOMMANDS = {
|
|
|
22
20
|
'mimi-seed-firebase': () => import('./firebase/cli.js'),
|
|
23
21
|
'mimi-seed-admob': () => import('./admob/cli.js'),
|
|
24
22
|
'mimi-seed-ga4': () => import('./ga4/cli.js'),
|
|
23
|
+
'mimi-seed-tools': () => import('./tools-cli.js'),
|
|
25
24
|
'mimi-seed-release-doctor': () => import('./checks/release-doctor-cli.js'),
|
|
26
25
|
};
|
|
27
26
|
const USAGE = [
|
|
@@ -57,6 +56,11 @@ async function main() {
|
|
|
57
56
|
console.error(`mimi-seed-mcp ${version}: MCP server running on stdio, waiting for an MCP client. ` +
|
|
58
57
|
'It is not interactive — press Ctrl+C to exit. Run with --help for subcommands.');
|
|
59
58
|
}
|
|
59
|
+
// CLI subcommands and help can finish without loading the server's tool registrations.
|
|
60
|
+
const [{ StdioServerTransport }, { buildServer }] = await Promise.all([
|
|
61
|
+
import('@modelcontextprotocol/sdk/server/stdio.js'),
|
|
62
|
+
import('./server.js'),
|
|
63
|
+
]);
|
|
60
64
|
const server = buildServer(version);
|
|
61
65
|
const transport = new StdioServerTransport();
|
|
62
66
|
await server.connect(transport);
|
package/dist/lib/cli-args.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare function flagList(p: ParsedArgs, name: string): string[] | undefi
|
|
|
18
18
|
export declare class CliUsageError extends Error {
|
|
19
19
|
}
|
|
20
20
|
/** 결과 JSON 을 stdout 으로 출력 (stderr 는 진행/안내용). */
|
|
21
|
-
export declare function printJson(data: unknown): void
|
|
21
|
+
export declare function printJson(data: unknown): Promise<void>;
|
|
22
22
|
/**
|
|
23
23
|
* 도메인 sub-CLI 공통 러너. requireAuth → 핸들러 매핑 실행 → JSON 출력 → exit code.
|
|
24
24
|
* 핸들러는 ParsedArgs 를 받아 출력할 데이터를 반환한다.
|
package/dist/lib/cli-args.js
CHANGED
|
@@ -60,7 +60,15 @@ export class CliUsageError extends Error {
|
|
|
60
60
|
}
|
|
61
61
|
/** 결과 JSON 을 stdout 으로 출력 (stderr 는 진행/안내용). */
|
|
62
62
|
export function printJson(data) {
|
|
63
|
-
process.
|
|
63
|
+
// process.exit() 전에 리포트 전체가 파이프로 전달될 때까지 기다린다.
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
process.stdout.write(JSON.stringify(data, null, 2) + '\n', (error) => {
|
|
66
|
+
if (error)
|
|
67
|
+
reject(error);
|
|
68
|
+
else
|
|
69
|
+
resolve();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
64
72
|
}
|
|
65
73
|
/**
|
|
66
74
|
* 도메인 sub-CLI 공통 러너. requireAuth → 핸들러 매핑 실행 → JSON 출력 → exit code.
|
|
@@ -79,7 +87,7 @@ export async function runDomainCli(opts) {
|
|
|
79
87
|
}
|
|
80
88
|
try {
|
|
81
89
|
const result = await handler(p);
|
|
82
|
-
printJson(result);
|
|
90
|
+
await printJson(result);
|
|
83
91
|
process.exit(0);
|
|
84
92
|
}
|
|
85
93
|
catch (e) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ToolManifest } from './package-root.js';
|
|
2
|
+
import type { ToolsetSelection } from './toolsets.js';
|
|
3
|
+
export declare const TOOL_MENU_URI = "mimi-seed://tools/menu";
|
|
4
|
+
export declare const TOOL_SELECTION_URI = "mimi-seed://tools/menu/{areas*}";
|
|
5
|
+
export type MenuLanguage = 'ko' | 'en';
|
|
6
|
+
export interface ToolMenuArea {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
tools: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function buildToolMenu(manifest: ToolManifest, selection: ToolsetSelection, lang: MenuLanguage): ToolMenuArea[];
|
|
12
|
+
export declare function formatToolMenu(menu: readonly ToolMenuArea[], lang: MenuLanguage): string;
|
|
13
|
+
export declare function selectToolMenu(menu: readonly ToolMenuArea[], input: string): {
|
|
14
|
+
areas: {
|
|
15
|
+
id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}[];
|
|
18
|
+
tools: string[];
|
|
19
|
+
} | null;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export const TOOL_MENU_URI = 'mimi-seed://tools/menu';
|
|
2
|
+
export const TOOL_SELECTION_URI = `${TOOL_MENU_URI}/{areas*}`;
|
|
3
|
+
const menuOrder = [
|
|
4
|
+
'ga4', 'bigquery', 'playstore', 'appstore', 'video', 'youtube', 'firebase', 'googleads',
|
|
5
|
+
'admob', 'drive', 'gsc', 'naver', 'instagram', 'threads', 'facebook', 'tiktok',
|
|
6
|
+
'ci', 'jenkins', 'checks', 'android', 'iam', 'billing', 'ai', 'auth',
|
|
7
|
+
];
|
|
8
|
+
const labels = {
|
|
9
|
+
ga4: { ko: 'GA4', en: 'GA4' },
|
|
10
|
+
playstore: { ko: 'Mobile Store · Google Play', en: 'Mobile Store · Google Play' },
|
|
11
|
+
appstore: { ko: 'Mobile Store · Apple App Store', en: 'Mobile Store · Apple App Store' },
|
|
12
|
+
video: { ko: 'YouTube · 영상 제작', en: 'YouTube · Video production' },
|
|
13
|
+
youtube: { ko: 'YouTube · 업로드·채널 운영', en: 'YouTube · Upload and channel management' },
|
|
14
|
+
naver: { ko: '네이버 서치어드바이저', en: 'Naver Search Advisor' },
|
|
15
|
+
checks: { ko: '출시 상태·제출 전 점검', en: 'Release status and submission checks' },
|
|
16
|
+
android: { ko: 'Android 서명', en: 'Android signing' },
|
|
17
|
+
ai: { ko: 'AI 초안 · 릴리스 노트 / 리뷰 답변', en: 'AI drafts · Release notes and review replies' },
|
|
18
|
+
auth: { ko: '계정 연결·진단', en: 'Account connections and diagnostics' },
|
|
19
|
+
};
|
|
20
|
+
export function buildToolMenu(manifest, selection, lang) {
|
|
21
|
+
const toolsByArea = new Map();
|
|
22
|
+
for (const [owner, domain] of Object.entries(manifest.domains)) {
|
|
23
|
+
for (const name of domain.tools) {
|
|
24
|
+
if (!selection.isToolEnabled(name) || Object.hasOwn(manifest.deprecated ?? {}, name))
|
|
25
|
+
continue;
|
|
26
|
+
// 영상 제작 쪽에 등록된 YouTube 업로드 도구도 메뉴에서는 채널 운영에 넣는다.
|
|
27
|
+
const area = owner === 'video' && name.startsWith('youtube_') ? 'youtube' : owner;
|
|
28
|
+
const areas = new Set([area, ...(manifest.alsoInToolsets?.[name] ?? [])]);
|
|
29
|
+
for (const id of areas) {
|
|
30
|
+
const tools = toolsByArea.get(id) ?? [];
|
|
31
|
+
tools.push(name);
|
|
32
|
+
toolsByArea.set(id, tools);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const ids = new Set([...menuOrder, ...Object.keys(manifest.domains)]);
|
|
37
|
+
return [...ids].flatMap((id) => {
|
|
38
|
+
const tools = toolsByArea.get(id);
|
|
39
|
+
const domain = manifest.domains[id];
|
|
40
|
+
return tools && domain ? [{ id, label: labels[id]?.[lang] ?? domain.label, tools }] : [];
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export function formatToolMenu(menu, lang) {
|
|
44
|
+
const question = lang === 'ko'
|
|
45
|
+
? '이번에 사용할 서비스를 골라주세요. 여러 개를 선택할 수 있습니다.'
|
|
46
|
+
: 'Which services would you like to use? You can choose more than one.';
|
|
47
|
+
return [question, '', ...menu.map(({ id, label }, index) => `${index + 1}. ${label} (${id})`)].join('\n');
|
|
48
|
+
}
|
|
49
|
+
export function selectToolMenu(menu, input) {
|
|
50
|
+
const entries = input.split(',').map((value) => value.trim().toLowerCase());
|
|
51
|
+
const areas = entries.map((entry) => /^\d+$/.test(entry)
|
|
52
|
+
? menu[Number(entry) - 1]
|
|
53
|
+
: menu.find(({ id, label }) => id === entry || label.toLowerCase() === entry));
|
|
54
|
+
if (areas.some((area) => area === undefined))
|
|
55
|
+
return null;
|
|
56
|
+
const selected = [...new Set(areas.filter((area) => area !== undefined))];
|
|
57
|
+
return {
|
|
58
|
+
areas: selected.map(({ id, label }) => ({ id, label })),
|
|
59
|
+
tools: [...new Set(selected.flatMap(({ tools }) => tools))],
|
|
60
|
+
};
|
|
61
|
+
}
|
package/dist/lib/toolsets.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ import type { ToolManifest } from './package-root.js';
|
|
|
9
9
|
* - `MIMI_SEED_TOOLSETS` 쉼표 구분. manifest 도메인 키(`playstore`) 또는 manifest
|
|
10
10
|
* `toolsets` 의 그룹 키(`store`), 그리고 내장 키워드 `all`.
|
|
11
11
|
* - `MIMI_SEED_TOOLSETS_EXCLUDE` 같은 문법. include 결과에서 뺀다.
|
|
12
|
-
* - manifest `alwaysOn`(auth · checks)은
|
|
13
|
-
*
|
|
12
|
+
* - manifest `alwaysOn`(auth · checks)은 도메인 필터에서 항상 켜진다.
|
|
13
|
+
* - `MIMI_SEED_TOOLS` 는 도메인 필터를 통과한 도구 중 실행기가 명시한 이름만 등록한다.
|
|
14
14
|
* - 도구 단위 판정: 도구는 자기 도메인 + manifest `alsoInToolsets` 의 도메인들에 속한다. 그중 하나라도
|
|
15
15
|
* include 되면 켜지고, 하나라도 exclude 되면 꺼진다 (alwaysOn 소속이면 항상 켜짐). 예: video.ts 가 등록하는
|
|
16
16
|
* `youtube_upload_video` 는 `youtube` 로도 켜지고, android.ts 의 `jenkins_upload_playstore_sa` 는 `jenkins` 로도 켜진다.
|
|
@@ -19,6 +19,7 @@ import type { ToolManifest } from './package-root.js';
|
|
|
19
19
|
*/
|
|
20
20
|
export declare const TOOLSETS_ENV = "MIMI_SEED_TOOLSETS";
|
|
21
21
|
export declare const TOOLSETS_EXCLUDE_ENV = "MIMI_SEED_TOOLSETS_EXCLUDE";
|
|
22
|
+
export declare const TOOL_NAMES_ENV = "MIMI_SEED_TOOLS";
|
|
22
23
|
export interface ToolsetSelection {
|
|
23
24
|
/** 켜진 도메인 키 집합 (alwaysOn 포함). 도메인 밖 도구의 소속(alsoInToolsets)은 isToolEnabled 가 본다. */
|
|
24
25
|
enabled: ReadonlySet<string>;
|
|
@@ -29,6 +30,7 @@ export interface ToolsetSelection {
|
|
|
29
30
|
/** 사용자가 준 원문 (정규화된 키 목록). */
|
|
30
31
|
include: string[];
|
|
31
32
|
exclude: string[];
|
|
33
|
+
toolNames?: string[];
|
|
32
34
|
/** 무시한 키 등 사용자에게 보여줄 경고. */
|
|
33
35
|
warnings: string[];
|
|
34
36
|
}
|
package/dist/lib/toolsets.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* - `MIMI_SEED_TOOLSETS` 쉼표 구분. manifest 도메인 키(`playstore`) 또는 manifest
|
|
9
9
|
* `toolsets` 의 그룹 키(`store`), 그리고 내장 키워드 `all`.
|
|
10
10
|
* - `MIMI_SEED_TOOLSETS_EXCLUDE` 같은 문법. include 결과에서 뺀다.
|
|
11
|
-
* - manifest `alwaysOn`(auth · checks)은
|
|
12
|
-
*
|
|
11
|
+
* - manifest `alwaysOn`(auth · checks)은 도메인 필터에서 항상 켜진다.
|
|
12
|
+
* - `MIMI_SEED_TOOLS` 는 도메인 필터를 통과한 도구 중 실행기가 명시한 이름만 등록한다.
|
|
13
13
|
* - 도구 단위 판정: 도구는 자기 도메인 + manifest `alsoInToolsets` 의 도메인들에 속한다. 그중 하나라도
|
|
14
14
|
* include 되면 켜지고, 하나라도 exclude 되면 꺼진다 (alwaysOn 소속이면 항상 켜짐). 예: video.ts 가 등록하는
|
|
15
15
|
* `youtube_upload_video` 는 `youtube` 로도 켜지고, android.ts 의 `jenkins_upload_playstore_sa` 는 `jenkins` 로도 켜진다.
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
export const TOOLSETS_ENV = 'MIMI_SEED_TOOLSETS';
|
|
20
20
|
export const TOOLSETS_EXCLUDE_ENV = 'MIMI_SEED_TOOLSETS_EXCLUDE';
|
|
21
|
+
export const TOOL_NAMES_ENV = 'MIMI_SEED_TOOLS';
|
|
21
22
|
function parseList(raw) {
|
|
22
23
|
if (!raw)
|
|
23
24
|
return [];
|
|
@@ -73,7 +74,7 @@ export function resolveToolsets(env, manifest) {
|
|
|
73
74
|
for (const tool of entry.tools)
|
|
74
75
|
membership.set(tool, [domain, ...(manifest.alsoInToolsets?.[tool] ?? [])]);
|
|
75
76
|
}
|
|
76
|
-
const
|
|
77
|
+
const isInSelectedToolsets = (name) => {
|
|
77
78
|
const domains = membership.get(name) ?? [];
|
|
78
79
|
if (domains.some((d) => always.has(d)))
|
|
79
80
|
return true;
|
|
@@ -81,13 +82,32 @@ export function resolveToolsets(env, manifest) {
|
|
|
81
82
|
return false;
|
|
82
83
|
return domains.some((d) => included.has(d));
|
|
83
84
|
};
|
|
85
|
+
const requestedTools = env[TOOL_NAMES_ENV];
|
|
86
|
+
const names = requestedTools === undefined ? undefined : new Set(parseList(requestedTools));
|
|
87
|
+
if (names) {
|
|
88
|
+
if (names.size === 0)
|
|
89
|
+
throw new Error(`${TOOL_NAMES_ENV} is empty. Supply tool names or unset it.`);
|
|
90
|
+
for (const name of names) {
|
|
91
|
+
if (!membership.has(name) || !isInSelectedToolsets(name)) {
|
|
92
|
+
throw new Error(`${TOOL_NAMES_ENV}: unavailable tool "${name}". Check the catalog and toolset settings.`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const selectedDomains = new Set([...names].flatMap((name) => membership.get(name) ?? []));
|
|
96
|
+
for (const domain of enabled) {
|
|
97
|
+
if (!selectedDomains.has(domain))
|
|
98
|
+
enabled.delete(domain);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const isToolEnabled = (name) => (!names || names.has(name)) && isInSelectedToolsets(name);
|
|
84
102
|
return {
|
|
85
103
|
enabled,
|
|
86
104
|
isToolEnabled,
|
|
87
105
|
// exclude 된 도메인이 있으면 다른 도메인 소속 도구(alsoInToolsets)도 빠질 수 있어 'all' 이 아니다.
|
|
88
|
-
all:
|
|
106
|
+
all: (!names || names.size === membership.size) &&
|
|
107
|
+
allDomains.every((d) => enabled.has(d)) && [...excluded].every((d) => always.has(d)),
|
|
89
108
|
include,
|
|
90
109
|
exclude,
|
|
110
|
+
...(names && { toolNames: [...names] }),
|
|
91
111
|
warnings,
|
|
92
112
|
};
|
|
93
113
|
}
|
|
@@ -99,6 +119,8 @@ export function knownKeys(manifest) {
|
|
|
99
119
|
export function describeToolsets(selection, manifest) {
|
|
100
120
|
if (selection.all)
|
|
101
121
|
return `all (${Object.keys(manifest.domains).length} domains)`;
|
|
122
|
+
if (selection.toolNames)
|
|
123
|
+
return `${TOOL_NAMES_ENV} (${selection.toolNames.length} tools)`;
|
|
102
124
|
const on = Object.keys(manifest.domains).filter((d) => selection.enabled.has(d));
|
|
103
125
|
return `${on.join(', ')} — ${TOOLSETS_ENV}/${TOOLSETS_EXCLUDE_ENV} 로 제한됨`;
|
|
104
126
|
}
|