Skip to main content
Glama

test-port-availability

Check if a specific port is available by entering its number, resolving connectivity issues in the MCP Troubleshooter diagnostic framework.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portYesPort number to test

Implementation Reference

  • The handler function tests port availability by attempting to create and listen on a temporary HTTP server on the given port. If it listens successfully, the port is available; if EADDRINUSE error, it's in use; other errors are reported.
    async ({ port }) => { return new Promise((resolve) => { const server = createServer(); server.once('error', (err) => { if (err.code === 'EADDRINUSE') { resolve({ content: [{ type: "text", text: `Port ${port} is already in use. This might indicate another server is running on this port.` }] }); } else { resolve({ isError: true, content: [{ type: "text", text: `Error testing port ${port}: ${err.message}` }] }); } server.close(); }); server.once('listening', () => { resolve({ content: [{ type: "text", text: `Port ${port} is available.` }] }); server.close(); }); server.listen(port, '127.0.0.1'); }); }
  • Zod schema defining the input parameter 'port' as an integer between 1 and 65535.
    { port: z.number().int().min(1).max(65535).describe("Port number to test") },
  • src/index.ts:520-556 (registration)
    Registers the tool 'test-port-availability' on the MCP server, including schema and inline handler implementation.
    server.tool( "test-port-availability", { port: z.number().int().min(1).max(65535).describe("Port number to test") }, async ({ port }) => { return new Promise((resolve) => { const server = createServer(); server.once('error', (err) => { if (err.code === 'EADDRINUSE') { resolve({ content: [{ type: "text", text: `Port ${port} is already in use. This might indicate another server is running on this port.` }] }); } else { resolve({ isError: true, content: [{ type: "text", text: `Error testing port ${port}: ${err.message}` }] }); } server.close(); }); server.once('listening', () => { resolve({ content: [{ type: "text", text: `Port ${port} is available.` }] }); server.close(); }); server.listen(port, '127.0.0.1'); }); } );

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/devlimelabs/mcp-troubleshooter-mcp'

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