list_views
Retrieve the list of all views in the current MySQL database for schema discovery and analysis.
Instructions
List all views in the current database.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:83-99 (registration)Registration of the 'list_views' tool. Uses server.registerTool with a name of 'list_views', a Zod schema with no inputs, and an async handler that queries information_schema.VIEWS to list all views in the current database.
server.registerTool( 'list_views', { description: 'List all views in the current database.', inputSchema: z.object({}), }, async () => { const results = await db.query(` SELECT TABLE_NAME, VIEW_DEFINITION FROM information_schema.VIEWS WHERE TABLE_SCHEMA = DATABASE() `); return { content: [{ type: 'text', text: JSON.stringify(results, null, 2) }], }; } ); - src/index.ts:89-98 (handler)The actual handler function for the 'list_views' tool. It queries information_schema.VIEWS for TABLE_NAME and VIEW_DEFINITION filtered by the current database schema, then returns the results as JSON text.
async () => { const results = await db.query(` SELECT TABLE_NAME, VIEW_DEFINITION FROM information_schema.VIEWS WHERE TABLE_SCHEMA = DATABASE() `); return { content: [{ type: 'text', text: JSON.stringify(results, null, 2) }], }; } - src/index.ts:87-88 (schema)Input schema for the 'list_views' tool. Defined as z.object({}) — no input parameters required.
inputSchema: z.object({}), }, - src/db.ts:42-45 (helper)The query helper function used by the list_views handler to execute SQL queries against the MySQL database.
export async function query(sql: string, params?: any[]) { const [rows] = await pool.query(sql, params); return rows; }