MCP Server Example with PRPs

This commit is contained in:
Cole Medin
2025-07-12 11:48:38 -05:00
parent 73d08d2236
commit 8445f05b67
42 changed files with 18567 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import type { Props } from '../../src/types'
export const mockProps: Props = {
login: 'testuser',
name: 'Test User',
email: 'test@example.com',
accessToken: 'test-access-token',
}
export const mockPrivilegedProps: Props = {
login: 'coleam00',
name: 'Cole Medin',
email: 'cole@example.com',
accessToken: 'privileged-access-token',
}
export const mockGitHubUser = {
data: {
login: 'testuser',
name: 'Test User',
email: 'test@example.com',
id: 12345,
avatar_url: 'https://github.com/images/avatar.png',
},
}
export const mockAuthRequest = {
clientId: 'test-client-id',
redirectUri: 'http://localhost:3000/callback',
scope: 'read:user',
state: 'test-state',
codeChallenge: 'test-challenge',
codeChallengeMethod: 'S256',
}
export const mockClientInfo = {
id: 'test-client-id',
name: 'Test Client',
description: 'A test OAuth client',
logoUrl: 'https://example.com/logo.png',
}
export const mockAccessToken = 'github-access-token-123'
export const mockAuthorizationCode = 'auth-code-456'
export const mockState = 'oauth-state-789'

View File

@@ -0,0 +1,64 @@
export const mockTableColumns = [
{
table_name: 'users',
column_name: 'id',
data_type: 'integer',
is_nullable: 'NO',
column_default: 'nextval(\'users_id_seq\'::regclass)',
},
{
table_name: 'users',
column_name: 'name',
data_type: 'character varying',
is_nullable: 'YES',
column_default: null,
},
{
table_name: 'users',
column_name: 'email',
data_type: 'character varying',
is_nullable: 'NO',
column_default: null,
},
{
table_name: 'posts',
column_name: 'id',
data_type: 'integer',
is_nullable: 'NO',
column_default: 'nextval(\'posts_id_seq\'::regclass)',
},
{
table_name: 'posts',
column_name: 'title',
data_type: 'text',
is_nullable: 'NO',
column_default: null,
},
{
table_name: 'posts',
column_name: 'user_id',
data_type: 'integer',
is_nullable: 'NO',
column_default: null,
},
]
export const mockQueryResult = [
{ id: 1, name: 'John Doe', email: 'john@example.com' },
{ id: 2, name: 'Jane Smith', email: 'jane@example.com' },
]
export const mockInsertResult = [
{ id: 3, name: 'New User', email: 'new@example.com' },
]
export const validSelectQuery = 'SELECT * FROM users WHERE id = 1'
export const validInsertQuery = 'INSERT INTO users (name, email) VALUES (\'Test\', \'test@example.com\')'
export const validUpdateQuery = 'UPDATE users SET name = \'Updated\' WHERE id = 1'
export const validDeleteQuery = 'DELETE FROM users WHERE id = 1'
export const dangerousDropQuery = 'DROP TABLE users'
export const dangerousDeleteAllQuery = 'SELECT * FROM users; DELETE FROM users WHERE 1=1'
export const maliciousInjectionQuery = 'SELECT * FROM users; DROP TABLE users; --'
export const emptyQuery = ''
export const whitespaceQuery = ' '

View File

@@ -0,0 +1,38 @@
import type { McpResponse } from '../../src/types'
export const mockSuccessResponse: McpResponse = {
content: [
{
type: 'text',
text: '**Success**\n\nOperation completed successfully',
},
],
}
export const mockErrorResponse: McpResponse = {
content: [
{
type: 'text',
text: '**Error**\n\nSomething went wrong',
isError: true,
},
],
}
export const mockQueryResponse: McpResponse = {
content: [
{
type: 'text',
text: '**Query Results**\n```sql\nSELECT * FROM users\n```\n\n**Results:**\n```json\n[\n {\n "id": 1,\n "name": "John Doe"\n }\n]\n```\n\n**Rows returned:** 1',
},
],
}
export const mockTableListResponse: McpResponse = {
content: [
{
type: 'text',
text: '**Database Tables and Schema**\n\n[\n {\n "name": "users",\n "schema": "public",\n "columns": [\n {\n "name": "id",\n "type": "integer",\n "nullable": false,\n "default": "nextval(\'users_id_seq\'::regclass)"\n }\n ]\n }\n]\n\n**Total tables found:** 1\n\n**Note:** Use the `queryDatabase` tool to run SELECT queries, or `executeDatabase` tool for write operations (if you have write access).',
},
],
}