MCPcopy Create free account
hub / github.com/21st-dev/21st-sdk / deploy

Function deploy

packages/cli/src/deploy.ts:124–297  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

122}
123
124export async function deploy() {
125 p.intro("@21st-sdk/cli deploy")
126
127 // 1. Check auth
128 const apiKey = getApiKey()
129 if (!apiKey) {
130 p.log.error(
131 "Not logged in. Run `npx @21st-sdk/cli login` first, or set API_KEY_21ST.",
132 )
133 process.exit(1)
134 }
135
136 // Deprecation notice for old project config
137 if (existsSync(join(process.cwd(), ".an", "project.json"))) {
138 p.log.warn(".an/project.json is no longer used and can be removed.")
139 }
140
141 // 2. Find agent entry points
142 let agents
143 try {
144 agents = await findAgentEntryPoints()
145 } catch (err: any) {
146 p.log.error(err.message)
147 process.exit(1)
148 }
149
150 const onlySlug = getFlag("--agent")
151 if (onlySlug) {
152 agents = agents.filter((a) => a.slug === onlySlug)
153 if (agents.length === 0) {
154 p.log.error(
155 `No agent with slug "${onlySlug}" in ./agents/ (see npx @21st-sdk/cli deploy --help)`,
156 )
157 process.exit(1)
158 }
159 }
160
161 const nameOverride = getFlag("--name")
162 if (nameOverride) {
163 const slugError = validateSlug(nameOverride)
164 if (slugError) {
165 p.log.error(`Invalid --name "${nameOverride}": ${slugError}`)
166 process.exit(1)
167 }
168 if (agents.length > 1) {
169 p.log.error(
170 `--name can only be used when deploying a single agent. Use --agent to select one.`,
171 )
172 process.exit(1)
173 }
174 }
175
176 p.log.info(`Found ${agents.length} agent${agents.length > 1 ? "s" : ""}`)
177
178 // 3. Deploy each agent
179 const deployed: { slug: string }[] = []
180
181 for (const agent of agents) {

Callers 1

index.tsFile · 0.85

Calls 15

getApiKeyFunction · 0.85
findAgentEntryPointsFunction · 0.85
getFlagFunction · 0.85
validateSlugFunction · 0.85
buildGoAgentFunction · 0.85
bundleAgentFunction · 0.85
createTemplateArchiveFunction · 0.85
readSiblingMcpConfigFunction · 0.85
extractSandboxConfigFunction · 0.85
extractAgentMetadataFunction · 0.85
hasMcpConfigConflictFunction · 0.85
readErrorMessageFunction · 0.85

Tested by

no test coverage detected