feat: add server assembly and stdio entry

This commit is contained in:
smartass
2026-06-12 00:13:10 +05:00
parent 7514aedb1e
commit 6bf2aa74ca
6 changed files with 120 additions and 8 deletions
+37
View File
@@ -0,0 +1,37 @@
import { mkdtempSync, rmSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { createRegistry } from '../../src/config/registry.js'
import { createServer } from '../../src/server.js'
import { connectClient, fakeManager } from './helpers.js'
describe('createServer', () => {
let dir: string
beforeEach(() => {
dir = mkdtempSync(join(tmpdir(), 'dbmole-server-'))
})
afterEach(() => {
rmSync(dir, { recursive: true, force: true })
})
it('registers all nine tools', async () => {
const registry = createRegistry({ storePath: join(dir, 'connections.json'), env: {} })
const server = createServer(registry, fakeManager())
const client = await connectClient(server)
const { tools } = await client.listTools()
expect(tools.map((tool) => tool.name).sort()).toEqual([
'add_connection',
'describe_table',
'execute_sql',
'list_connections',
'list_databases',
'list_tables',
'remove_connection',
'test_connection',
'update_connection'
])
})
})