Skip to main content
Glama

Notion MCP Server

by ccabanillas
client.cpython-313.pyc7.69 kB
� �|OgX��X�SrSSKrSSKJrJrJrJr SSKrSSKJ r J r J r "SS5r g)z!Notion API client implementation.�N)�Any�Dict�List�Optional�)�Database�Page� SearchResultsc�d�\rSrSrSrS\4SjrS\\4Sjr SS\S \ \ \\ 4S \ \\ \\ 4S \ \S \ S\ \\ 44 S jjrSS\S\ \\ 4S\ \\ \\ 4S\4SjjrSS\S\ \\ 4S\ \S\4SjjrSS\S \ \ \\ 4S\ \ \\ 4S \ \S \ S\4 SjjrSrg)� NotionClient�z+Client for interacting with the Notion API.�api_keyc�:�XlSUlSU3SSS.Ulg)zAInitialize the Notion client. Args: api_key: Notion API key zhttps://api.notion.com/v1zBearer zapplication/jsonz 2022-06-28)� Authorizationz Content-TypezNotion-VersionN�r�base_url�headers)�selfrs �C/Users/chasecabanillas/Projects/notion-mcp/src/notion_mcp/client.py�__init__�NotionClient.__init__ s)�� � �3�� �&�w�i�0�.�*� �� ��returnc ���# �[R"5IShv�N nURURS3URSSS.SSSS .S .S 9IShv�N nUR 5 UR 5nURS 5(d/sSSS5IShv�N $US Vs/sHn[S 0UD6PM snsSSS5IShv�N $N�N~N8s snfN!,IShv�N (df  g=f7f)z1List all databases the integration has access to.N�/search�object�database)�property�value�d� descending�last_edited_time)� direction� timestamp)�filter� page_size�sort�r�json�results�) �httpx� AsyncClient�postrr�raise_for_statusr)�getr)r�client�response�data�dbs r�list_databases�NotionClient.list_databasess�����$�$�&�&�&�#�[�[��=�=�/��)�� � �%-�!+��"%�%1�%7�� �)���H� � %� %� '��=�=�?�D��8�8�I�&�&��''�&�&�(.2�)�_�=�_�r�H�N�r�N�_�=�)'�&�&��'��(>�)'�&�&�&�s��C:�C�C:�6C �C�;C � C:�C�C:�$C �+C�?C � C:� C�C:�C �C:�C �C:� C7�&C) �' C7�3C:N� database_idr%�sorts� start_cursorr&c��# �SU0nU(aX&S'U(aX6S'U(aXFS'[R"5IShv�N nURURSUS3URUS9IShv�N nUR 5 UR 5sSSS5IShv�N $NhN7N !,IShv�N (df  g=f7f) zQuery a database.r&r%r8r9Nz /databases/z/queryr()r,r-r.rrr/r)) rr7r%r8r9r&�bodyr1r2s r�query_database�NotionClient.query_database1s���� �� �� �#��N� �!��M� �#/�� ��$�$�&�&�&�#�[�[��=�=�/��[�M��@�� � ��)���H� � %� %� '��=�=�?�'�&�&��'�&�&�&�sY�?C �B*�C �/B0�4B,�5#B0� C �$B.�%C �,B0�.C �0C�6B9 �7 C�C � parent_id� properties�childrenc��~# �SU0US.nU(aX4S'[R"5IShv�N nURURS3URUS9IShv�N nUR 5 [ S0UR5D6sSSS5IShv�N $NnN@N !,IShv�N (df  g=f7f)zCreate a new page.r7)�parentr?r@Nz/pagesr(r+)r,r-r.rrr/r r))rr>r?r@r;r1r2s r� create_page�NotionClient.create_pageMs����%�i�0�$� �� �'�� ��$�$�&�&�&�#�[�[��=�=�/��(�� � ��)���H� � %� %� '��*�(�-�-�/�*�'�&�&��'�&�&�&�sV�,B=�B�B=�,B#�B�,B#� B=�B!�B=�B#�!B=�#B:�)B, �* B:�6B=�page_id�archivedc��t# �SU0nUbX4S'[R"5IShv�N nURURSU3URUS9IShv�N nUR 5 [ S0UR5D6sSSS5IShv�N $NpN@N !,IShv�N (df  g=f7f)zUpdate a page.r?NrFz/pages/r(r+)r,r-�patchrrr/r r))rrEr?rFr;r1r2s r� update_page�NotionClient.update_pageds�����j�)�� � �'�� ��$�$�&�&�&�#�\�\��=�=�/��� �2�� � ��*���H� � %� %� '��*�(�-�-�/�*�'�&�&��'�&�&�&�sV�%B8�B�B8�.B�B�,B� B8�B�B8�B�B8�B5�$B' �% B5�1B8�queryr'c ��0# �UUS.nU(aX&S'U(aX6S'U(aXFS'[R"5IShv�N nURURS3URUS9IShv�N nUR 5 UR 5n /n U RS/5H�n U S S :XaU R[S0U D65 M(U S S :XdM30n U RS 05R5Hup�[S0UD6X�'M X�S 'U R[S0U D65 M� [S U U RS5U RSS5S9sSSS5IShv�N $GN2GNN !,IShv�N (df  g=f7f)zSearch Notion.)rKr&r%r'r9Nrr(r*rr�pager?�list� next_cursor�has_moreF)rr*rOrPr+)r,r-r.rrr/r)r0�appendr�items� PropertyValuer r )rrKr%r'r9r&r;r1r2r3r*�itemr?�keyrs r�search�NotionClient.searchxsn����"� �� �#��N� ���L� �#/�� ��$�$�&�&�&�#�[�[��=�=�/��)�� � ��)���H� � %� %� '��=�=�?�D��G�����B�/����>�Z�/��N�N�8�#3�d�#3�4��(�^�v�-�!#�J�&*�h�h�|�R�&@�&F�&F�&H� ��*7�*@�%�*@� ��'I�)3��&��N�N�4�<�$�<�0�0�!��� �H�H�]�3����*�e�4� �-'�&�&��'�&�&�&�sb�AF�E4�F�,E<�2E7�3A'E<�BE<�" F�.E:�/F�7E<�:F�<F�F � F�Fr)NNNr )N)�NNNr )�__name__� __module__� __qualname__�__firstlineno__�__doc__�strrrrr5rrr�intr<r rC�boolrIr rV�__static_attributes__r+rrr r s���5�  ��  �>�d�8�n�>�6,0�04�&*�� #��#���c�3�h��(�#���T�#�s�(�^�,�-� #� �s�m� #� � #� �c�3�h��#�@48� +��+���c��N�+��4��S�#�X��/�0� +� � +�6$(� +��+���c��N�+��4�.� +� � +�,�+/�)-�&*�� /��/���c�3�h��(�/��t�C��H�~�&� /� �s�m� /� � /� �/�/rr ) r]�os�typingrrrrr,� models.notionrr r r r+rr�<module>res&��'� �,�,� �8�8�_�_r

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/ccabanillas/notion-mcp'

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