소스 정보
- 저장소
- tools-only/X-Skills
- 최근 소스 활동
- 2026년 2월 9일 04:08
- 감지된 SKILL.md 언어
- 영어
- 스타
- 7
- 포크
- 1
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/tools-only/X-Skills --skill firestore-setup명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SKILL.md 표시 중
| name | firestore-setup |
| description | Initialize Firebase Admin SDK, configure Firestore, and setup A2A/MCP... |
| model | sonnet |
Initialize Firebase Admin SDK in your project with support for:
Set up Firebase Admin SDK with proper configuration for both regular users and AI agents. Guide the user through:
First, check if Firebase is already configured:
# Check if firebase-admin is installed
npm list firebase-admin
# Check for existing Firebase initialization
grep -r "firebase-admin" .
# Check for service account credentials
ls -la *.json | grep -i firebase
If Firebase is already set up, ask the user if they want to reconfigure.
# Install firebase-admin
npm install firebase-admin
# For A2A/MCP integration, also install:
npm install @google-cloud/firestore
npm install dotenv # For environment variables
Ask the user:
Option A: Download from Firebase Console
1. Go to https://console.firebase.google.com
2. Select your project
3. Settings (gear icon) → Project Settings → Service Accounts
4. Click "Generate new private key"
5. Save JSON file to your project (e.g., serviceAccountKey.json)
Option B: Use existing GCP credentials
# If using Google Cloud SDK
gcloud auth application-default login
Option C: Environment variable (production)
# Set environment variable
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/serviceAccountKey.json"
Create src/firebase.js (or src/firebase.ts for TypeScript):
const admin = require('firebase-admin');
// Initialize Firebase Admin SDK
if (!admin.apps.length) {
// Option 1: Using service account key file
const serviceAccount = require('../serviceAccountKey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: `https://${serviceAccount.project_id}.firebaseio.com`
});
// Option 2: Using environment variable (recommended for production)
// admin.initializeApp({
// credential: admin.credential.applicationDefault(),
// projectId: process.env.FIREBASE_PROJECT_ID
// });
}
const db = admin.firestore();
// Export for use in other files
module.exports = { admin, db };
For TypeScript:
import * as admin from 'firebase-admin';
if (!admin.apps.length) {
const serviceAccount = require('../serviceAccountKey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: `https://${serviceAccount.project_id}.firebaseio.com`
});
}
export const db = admin.firestore();
export { admin };
Create a test script to verify Firestore works:
const { db } = require('./src/firebase');
async function testFirestore() {
try {
// Test write
const testRef = await db.collection('_test').add({
message: 'Firebase connected successfully!',
timestamp: admin.firestore.FieldValue.serverTimestamp()
});
console.log('✅ Write successful. Document ID:', testRef.id);
// Test read
const doc = await testRef.get();
console.log('✅ Read successful. Data:', doc.data());
// Clean up test document
await testRef.delete();
console.log('✅ Delete successful');
console.log('\n🎉 Firebase is configured correctly!');
} catch (error) {
console.error('❌ Error:', error.message);
process.exit(1);
}
}
();
Run the test:
node test-firestore.js
If the user needs A2A or MCP integration, create additional configuration:
A. Create A2A configuration file (src/a2a-config.js):
const { db } = require('./firebase');
// A2A Framework Configuration
const A2A_CONFIG = {
collections: {
sessions: 'agent_sessions',
memory: 'agent_memory',
tasks: 'a2a_tasks',
messages: 'a2a_messages',
logs: 'agent_logs'
},
serviceAccounts: [
'mcp-server@project-id.iam.gserviceaccount.com',
'agent-engine@project-id.iam.gserviceaccount.com'
],
sessionTTL: 3600, // 1 hour in seconds
messageTTL: 86400, // 24 hours
rateLimits: {
maxRequestsPerMinute: 100,
maxConcurrentSessions: 50
}
};
// Initialize A2A collections
async function initializeA2ACollections() {
const collections = Object.values(A2A_CONFIG.collections);
for (const collection of collections) {
const ref = db.collection(collection);
// Create initial document to establish collection
await ref.doc().({
: ,
: ()
});
.();
}
}
. = { , initializeA2ACollections };
B. Create MCP service integration (src/mcp-service.js):
const { db } = require('./firebase');
const { A2A_CONFIG } = require('./a2a-config');
class MCPService {
constructor(serviceAccountEmail) {
this.serviceAccountEmail = serviceAccountEmail;
this.db = db;
}
// Create a new agent session
async createSession(sessionData) {
const sessionRef = this.db.collection(A2A_CONFIG.collections.sessions).doc();
await sessionRef.set({
...sessionData,
agentId: this.serviceAccountEmail,
status: 'active',
createdAt: admin.firestore.FieldValue.serverTimestamp(),
expiresAt: new Date(Date.now() + A2A_CONFIG.sessionTTL * 1000)
});
return sessionRef.id;
}
// Store agent memory/context
() {
contextRef = .
.(..)
.(.)
.()
.(sessionId);
contextRef.({
...contextData,
: .,
sessionId,
: admin...()
});
}
() {
..(..).({
: .,
: toAgent,
payload,
: admin...(),
:
});
}
() {
snapshot = .
.(..)
.(, , .)
.(, , )
.(, )
.();
messages = [];
batch = ..();
snapshot.( {
messages.({ : doc., ...doc.() });
batch.(doc., { : });
});
batch.();
messages;
}
() {
..(..).({
: .,
activity,
level,
: admin...()
});
}
}
. = { };
C. Create Cloud Run service integration (src/cloudrun-service.js):
const { db } = require('./firebase');
class CloudRunService {
constructor() {
this.db = db;
}
// Log API requests from Cloud Run
async logRequest(endpoint, method, userId, metadata = {}) {
await this.db.collection('api_requests').add({
endpoint,
method,
userId,
metadata,
timestamp: admin.firestore.FieldValue.serverTimestamp()
});
}
// Store API response
async storeResponse(requestId, responseData) {
await this.db.collection('api_responses').doc(requestId).set({
...responseData,
timestamp: admin.firestore.FieldValue.serverTimestamp()
});
}
// Get user data for Cloud Run service
async getUserData(userId) {
const doc = await this.db.collection('users').(userId).();
(!doc.) {
();
}
doc.();
}
}
. = { };
Create .env file:
# Firebase Configuration
GOOGLE_APPLICATION_CREDENTIALS=./serviceAccountKey.json
FIREBASE_PROJECT_ID=your-project-id
# A2A Configuration (if applicable)
MCP_SERVICE_ACCOUNT_EMAIL=mcp-server@project-id.iam.gserviceaccount.com
AGENT_ENGINE_SERVICE_ACCOUNT=agent-engine@project-id.iam.gserviceaccount.com
# Cloud Run Configuration (if applicable)
CLOUD_RUN_SERVICE_URL=https://your-service-abc123-uc.a.run.app
Add to .gitignore:
serviceAccountKey.json
.env
Ask if the user wants to deploy initial security rules:
# Install Firebase CLI
npm install -g firebase-tools
# Login
firebase login
# Initialize Firestore rules
firebase init firestore
Then use the firestore-security-agent to generate appropriate rules based on their use case.
Create examples/firestore-usage.js:
const { db, admin } = require('../src/firebase');
// Example 1: Basic CRUD
async function basicCRUD() {
// Create
const docRef = await db.collection('users').add({
name: 'John Doe',
email: '[email protected]',
createdAt: admin.firestore.FieldValue.serverTimestamp()
});
// Read
const doc = await docRef.get();
console.log('User data:', doc.data());
// Update
await docRef.update({
name: 'John Updated',
updatedAt: admin.firestore.FieldValue.serverTimestamp()
});
// Delete
await docRef.delete();
}
// Example 2: Queries
async function queryExamples() {
// Simple query
const activeUsers = await db.collection()
.(, , )
.()
.();
activeUsers.( {
.(doc., doc.());
});
recentOrders = db.()
.(, , )
.(, , )
.(, )
.()
.();
}
() {
batch = db.();
( i = ; i < ; i++) {
ref = db.().();
batch.(ref, {
: ,
: admin...()
});
}
batch.();
.();
}
() {
{ } = ();
mcp = ();
sessionId = mcp.({
: ,
:
});
mcp.(sessionId, {
: ,
:
});
mcp.(
,
{ : , : { : } }
);
mcp.(, );
}
. = { basicCRUD, queryExamples, batchOperations, a2aExample };
Verify the following after setup:
.gitignore includes serviceAccountKey.json and .envTell the user:
node test-firestore.jsexamples/firestore-usage.js/firestore-security-agent to generate rules/firebase-operations-agent for CRUD operationsnpm install firebase-adminCongratulations! Your Firestore setup is complete! 🎉
SOC 직업 분류 기준