Skip to main content
Glama
utils.ts1.65 kB
import { Api } from '@neondatabase/api-client'; import { handleListProjects } from './list-projects.js'; import { ToolHandlerExtraParams } from '../types.js'; import { NotFoundError } from '../../server/errors.js'; import { looksLikeBranchId, looksLikeProjectId } from '../utils.js'; type MCPOrgId = `org:${string}`; type MCPProjectId = `project:${string}`; type MCPBranchId = `branch:${string}/${string}`; // projectId/branchId export type SearchResultId = MCPOrgId | MCPProjectId | MCPBranchId; export const isOrgId = (id: string): id is MCPOrgId => { return id.startsWith('org:') || id.startsWith('org-'); }; export const isProjectId = (id: string): id is MCPProjectId => { return id.startsWith('project:') || looksLikeProjectId(id); }; export const isBranchId = (id: string): id is MCPProjectId => { return id.startsWith('branch:') || looksLikeBranchId(id); }; export async function getOnlyProject( neonClient: Api<unknown>, extra: ToolHandlerExtraParams, ) { const projects = await handleListProjects({}, neonClient, extra); if (projects.length === 1) { return projects[0]; } throw new NotFoundError( 'Please provide a project ID or ensure you have only one project in your account.', ); } export const getDefaultBranch = async ( projectId: string, neonClient: Api<unknown>, ) => { const branches = await neonClient.listProjectBranches({ projectId, }); const defaultBranch = branches.data.branches.find((branch) => branch.default); if (defaultBranch) { return defaultBranch; } throw new NotFoundError( 'No default branch found in this project. Please provide a branch ID.', ); };

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/neondatabase-labs/mcp-server-neon'

If you have feedback or need assistance with the MCP directory API, please join our Discord server