@yoonion/mimi-seed-mcp 0.19.3 → 0.19.4

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.
@@ -8,7 +8,7 @@ export type BillingInfo = {
8
8
  /** 사람이 읽을 판정 — Blaze/Spark 오판을 막기 위해 문장으로 준다. */
9
9
  verdict: string;
10
10
  };
11
- export declare function getBillingInfo(auth: OAuth2Client, projectId: string): Promise<BillingInfo>;
11
+ export declare function getBillingInfo(auth: OAuth2Client, projectId: string, quotaProjectId?: string): Promise<BillingInfo>;
12
12
  /**
13
13
  * 결제 계정에 붙은 프로젝트 목록 = **비용 범위 확인**.
14
14
  * 여기서 프로젝트가 여러 개면 계정 전체 예산은 의미가 없고 프로젝트 필터를 써야 한다.
@@ -44,12 +44,13 @@ export function normalizeBillingAccount(input) {
44
44
  const trimmed = input.trim();
45
45
  return trimmed.startsWith('billingAccounts/') ? trimmed : `billingAccounts/${trimmed}`;
46
46
  }
47
- export async function getBillingInfo(auth, projectId) {
48
- // 조회 대상 프로젝트 자신을 quota 주체로 쓴다 — 거기 Billing API 가 켜져 있어야 한다.
47
+ export async function getBillingInfo(auth, projectId, quotaProjectId = projectId) {
48
+ // 기본은 조회 대상 프로젝트를 quota 주체로 쓰되, Spark 프로젝트처럼 유료 API를
49
+ // 소비할 수 없는 대상은 별도의 Blaze quota 프로젝트를 지정할 수 있다.
49
50
  const res = await billing().projects.getBillingInfo({
50
51
  auth,
51
52
  name: `projects/${projectId}`,
52
- ...quotaHeaders(projectId),
53
+ ...quotaHeaders(quotaProjectId),
53
54
  });
54
55
  const enabled = res.data.billingEnabled ?? false;
55
56
  const account = res.data.billingAccountName ?? null;
@@ -32,8 +32,10 @@ export declare function getRemoteConfigOverview(auth: OAuth2Client, input: {
32
32
  projectId: string;
33
33
  namespace?: string;
34
34
  days?: number;
35
+ quotaProjectId?: string;
35
36
  }): Promise<{
36
37
  projectId: string;
38
+ quotaProjectId: string;
37
39
  namespace: string;
38
40
  pricingPolicy: {
39
41
  effectiveDate: string;
@@ -3,6 +3,7 @@ import { getBillingInfo } from '../billing/tools.js';
3
3
  const FREE_DAILY_FETCHES = 100_000;
4
4
  const FIRST_PAID_TIER_END = 10_000_000;
5
5
  const REMOTE_CONFIG_BASE = 'https://firebaseremoteconfig.googleapis.com/v1';
6
+ const FIREBASE_MANAGEMENT_BASE = 'https://firebase.googleapis.com/v1beta1';
6
7
  export function countStates(items) {
7
8
  const counts = {};
8
9
  for (const item of items) {
@@ -11,9 +12,12 @@ export function countStates(items) {
11
12
  }
12
13
  return counts;
13
14
  }
14
- async function optionalRequest(auth, url) {
15
+ async function optionalRequest(auth, url, quotaProjectId) {
15
16
  try {
16
- const response = await auth.request({ url });
17
+ const response = await auth.request({
18
+ url,
19
+ headers: { 'x-goog-user-project': quotaProjectId },
20
+ });
17
21
  return { available: true, data: response.data };
18
22
  }
19
23
  catch (error) {
@@ -23,7 +27,7 @@ async function optionalRequest(auth, url) {
23
27
  };
24
28
  }
25
29
  }
26
- async function optionalPagedRequest(auth, url, field) {
30
+ async function optionalPagedRequest(auth, url, field, quotaProjectId) {
27
31
  try {
28
32
  const items = [];
29
33
  let pageToken;
@@ -33,7 +37,10 @@ async function optionalPagedRequest(auth, url, field) {
33
37
  requestUrl.searchParams.set('pageSize', '100');
34
38
  if (pageToken)
35
39
  requestUrl.searchParams.set('pageToken', pageToken);
36
- const response = await auth.request({ url: requestUrl.toString() });
40
+ const response = await auth.request({
41
+ url: requestUrl.toString(),
42
+ headers: { 'x-goog-user-project': quotaProjectId },
43
+ });
37
44
  const data = response.data;
38
45
  items.push(...(data[field] ?? []));
39
46
  pageToken = data.nextPageToken;
@@ -68,7 +75,7 @@ export function remoteConfigUsageLevel(fetches) {
68
75
  return 'warning';
69
76
  return 'ok';
70
77
  }
71
- async function fetchDailyUsage(auth, projectId, days) {
78
+ async function fetchDailyUsage(auth, projectId, days, quotaProjectId) {
72
79
  try {
73
80
  const end = new Date();
74
81
  const start = new Date(end.getTime() - days * 86_400_000);
@@ -84,6 +91,8 @@ async function fetchDailyUsage(auth, projectId, days) {
84
91
  'aggregation.crossSeriesReducer': 'REDUCE_SUM',
85
92
  view: 'FULL',
86
93
  pageSize: Math.max(days + 2, 10),
94
+ }, {
95
+ headers: { 'x-goog-user-project': quotaProjectId },
87
96
  });
88
97
  const points = (response.data.timeSeries ?? [])
89
98
  .flatMap((series) => series.points ?? [])
@@ -109,15 +118,32 @@ async function fetchDailyUsage(auth, projectId, days) {
109
118
  export async function getRemoteConfigOverview(auth, input) {
110
119
  const namespace = input.namespace ?? 'firebase';
111
120
  const days = Math.min(Math.max(input.days ?? 7, 1), 30);
121
+ // User OAuth otherwise charges quota to the shared OAuth-client project. The
122
+ // resource project is the safest default; Spark projects can point this at a
123
+ // separate Blaze project with the relevant APIs enabled.
124
+ const quotaProjectId = input.quotaProjectId ?? input.projectId;
112
125
  const encodedProject = encodeURIComponent(input.projectId);
113
126
  const encodedNamespace = encodeURIComponent(namespace);
114
127
  const parent = `${REMOTE_CONFIG_BASE}/projects/${encodedProject}/namespaces/${encodedNamespace}`;
128
+ // The rollout beta endpoint rejects project IDs even though the REST path uses
129
+ // the generic {project} placeholder; live responses require projectNumber.
130
+ const projectNumber = optionalRequest(auth, `${FIREBASE_MANAGEMENT_BASE}/projects/${encodedProject}`, quotaProjectId);
131
+ const rolloutsPromise = projectNumber.then(async (result) => {
132
+ if (!result.available || !result.data?.projectNumber) {
133
+ return {
134
+ available: false,
135
+ error: result.error ?? 'Firebase project number is unavailable.',
136
+ };
137
+ }
138
+ const rolloutParent = `${REMOTE_CONFIG_BASE}/projects/${encodeURIComponent(result.data.projectNumber)}/namespaces/${encodedNamespace}`;
139
+ return optionalPagedRequest(auth, `${rolloutParent}/rollouts`, 'rollouts', quotaProjectId);
140
+ });
115
141
  const [template, experiments, rollouts, usage, billing] = await Promise.all([
116
- optionalRequest(auth, `${parent}/remoteConfig`),
117
- optionalPagedRequest(auth, `${parent}/experiments`, 'experiments'),
118
- optionalPagedRequest(auth, `${parent}/rollouts`, 'rollouts'),
119
- fetchDailyUsage(auth, input.projectId, days),
120
- getBillingInfo(auth, input.projectId)
142
+ optionalRequest(auth, `${parent}/remoteConfig`, quotaProjectId),
143
+ optionalPagedRequest(auth, `${parent}/experiments`, 'experiments', quotaProjectId),
144
+ rolloutsPromise,
145
+ fetchDailyUsage(auth, input.projectId, days, quotaProjectId),
146
+ getBillingInfo(auth, input.projectId, quotaProjectId)
121
147
  .then((data) => ({ available: true, data }))
122
148
  .catch((error) => ({
123
149
  available: false,
@@ -167,6 +193,7 @@ export async function getRemoteConfigOverview(auth, input) {
167
193
  .map(summarizeRollout);
168
194
  return {
169
195
  projectId: input.projectId,
196
+ quotaProjectId,
170
197
  namespace,
171
198
  pricingPolicy: {
172
199
  effectiveDate: '2026-09-01',
@@ -38,9 +38,10 @@ export function registerFirebaseTools(server) {
38
38
  projectId: z.string().describe('Firebase / Google Cloud 프로젝트 ID'),
39
39
  namespace: z.string().optional().describe('Remote Config namespace (기본: firebase)'),
40
40
  days: z.number().int().min(1).max(30).optional().describe('사용량 조회 일수 (기본: 7, 최대: 30)'),
41
- }, async ({ projectId, namespace, days }) => {
41
+ quotaProjectId: z.string().optional().describe('API quota/과금 프로젝트 ID. 기본은 projectId. Spark 프로젝트의 Monitoring 조회가 billing_required이면 Remote Config·Monitoring API가 활성화된 Blaze 프로젝트를 지정'),
42
+ }, async ({ projectId, namespace, days, quotaProjectId }) => {
42
43
  const auth = await requireAuth();
43
- return jsonResult(await getRemoteConfigOverview(auth, { projectId, namespace, days }));
44
+ return jsonResult(await getRemoteConfigOverview(auth, { projectId, namespace, days, quotaProjectId }));
44
45
  });
45
46
  server.tool('firebase_list_projects', '내 Firebase 프로젝트 목록 조회', {}, async () => {
46
47
  const auth = await requireAuth();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoonion/mimi-seed-mcp",
3
- "version": "0.19.3",
3
+ "version": "0.19.4",
4
4
  "description": "Mimi Seed MCP server \u2014 Firebase + AdMob + Google Play + App Store management for Claude Code / Codex / Cursor / any MCP client.",
5
5
  "type": "module",
6
6
  "bin": {