We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/rhabraken/mcp-python'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
server.cpython-312.pyc•2.51 KiB
�
Q��gT � �v � d dl mZ d dlZd dlZd dlmZ e� ej dd� Z ej dd� Z ej dd � Z ej d
d� Z
ej dd
� Zd� Z ed� Z
e
j � defd�� Ze
j � dedefd�� Zy)� )�FastMCPN)�load_dotenv�DB_HOST�db�DB_PORT�5432�DB_NAME�
mydatabase�DB_USER�postgres�DB_PASSWORD�passwordc �V � t j dt t t t
�� S )z!Return a new database connection.� localhost)�host�port�database�userr )�psycopg2�connectr r r r
� � �-/Users/rick/Projects/mcp-python/app/server.py�get_db_connectionr s$ � ����
�
��
��� r z
Demo Donna�returnc � � t � } | j � 5 }|j d� |j � }ddd� | j � t � S # 1 sw Y �$xY w# t $ r}d|� �cY d}~S d}~ww xY w)�~
Executes a SQL query and returns the result as a string.
Example:
query_db("SELECT * FROM my_table;")
z*SELECT * FROM information_schema.schemata;N�Error: �r �cursor�execute�fetchall�close�str� Exception)�conn�cur�result�es r �
get_db_schemar* sq � �� �"��
�[�[�]�c��K�K�D�E��\�\�^�F� �
�
�
���6�{�� �]��
� ����}�����3 �A- �"A!�"A- �!A*�&A- �- B�6B �:B� B�queryc � � t � }|j � 5 }|j | � |j � }ddd� |j � t � S # 1 sw Y �$xY w# t $ r}d|� �cY d}~S d}~ww xY w)r Nr r )r, r&