Skip to main content
Glama
twodoorsdev
by twodoorsdev

getConnectedApps

Retrieve connected apps in a React Native project by specifying the Metro server port. Simplify debugging with actionable insights into active app connections.

Instructions

Get the connected apps

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
metroServerPortYesThe port number of the Metro server

Implementation Reference

  • Handler function that fetches connected apps via Metro server's inspector endpoint, returns formatted app JSON or error.
    handler: async ({ metroServerPort }: GetConnectedAppsSchema) => { const metroServerOrigin = `http://localhost:${metroServerPort}`; try { const apps = await queryAllInspectorAppsAsync(metroServerOrigin); if (!apps || apps.length === 0) { throw new Error( 'No connected apps found, please ensure that Metro is running', ); } return { content: apps.map((app) => ({ type: 'text', text: JSON.stringify(app, null, 2), })), }; } catch (error) { return { content: [ { type: 'text', text: `Error: ${(error as Error).message}`, }, ], isError: true, }; } },
  • Zod schema defining the input: metroServerPort (number). Includes TypeScript type export.
    export const getConnectedAppsSchema = z.object({ metroServerPort: z.number().describe('The port number of the Metro server'), }); export type GetConnectedAppsSchema = z.infer<typeof getConnectedAppsSchema>;
  • Primary tool registration object defining name, description, input schema, and handler reference.
    export const getConnectedAppsTool: ToolRegistration<GetConnectedAppsSchema> = { name: 'getConnectedApps', description: 'Get the connected apps', inputSchema: makeJsonSchema(getConnectedAppsSchema), handler: async ({ metroServerPort }: GetConnectedAppsSchema) => { const metroServerOrigin = `http://localhost:${metroServerPort}`; try { const apps = await queryAllInspectorAppsAsync(metroServerOrigin); if (!apps || apps.length === 0) { throw new Error( 'No connected apps found, please ensure that Metro is running', ); } return { content: apps.map((app) => ({ type: 'text', text: JSON.stringify(app, null, 2), })), }; } catch (error) { return { content: [ { type: 'text', text: `Error: ${(error as Error).message}`, }, ], isError: true, }; } }, };
  • Tool is imported and registered in the central createTools function, wrapping the handler.
    { ...getConnectedAppsTool, // biome-ignore lint/suspicious/noExplicitAny: All tools validate their input schemas, so any is fine. handler: (args: any) => getConnectedAppsTool.handler(args), },

Other Tools

Related Tools

Latest Blog Posts

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/twodoorsdev/react-native-debugger-mcp'

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