Skip to main content
Glama
main.py12.1 kB
# generated by fastapi-codegen: # filename: openapi.yaml # timestamp: 2025-06-29T07:51:02+00:00 import argparse import json import os from typing import * from typing import Optional from autogen.mcp.mcp_proxy import MCPProxy from autogen.mcp.mcp_proxy.security import BaseSecurity from fastapi import UploadFile from models import ( CreateAnswerRequest, CreateAnswerResponse, CreateChatCompletionRequest, CreateChatCompletionResponse, CreateClassificationRequest, CreateClassificationResponse, CreateCompletionRequest, CreateCompletionResponse, CreateEditRequest, CreateEditResponse, CreateEmbeddingRequest, CreateEmbeddingResponse, CreateFineTuneRequest, CreateImageRequest, CreateModerationRequest, CreateModerationResponse, CreateSearchRequest, CreateSearchResponse, CreateTranscriptionResponse, CreateTranslationResponse, DeleteFileResponse, DeleteModelResponse, Engine, FineTune, ImagesResponse, ListEnginesResponse, ListFilesResponse, ListFineTuneEventsResponse, ListFineTunesResponse, ListModelsResponse, Model, OpenAIFile, ) app = MCPProxy( description='APIs for sampling from and fine-tuning language models', title='OpenAI API', version='1.2.0', servers=[{'url': 'https://api.openai.com/v1'}], ) @app.post( '/answers', tags=['text_completion_services', 'query_search_and_classification'] ) def create_answer(body: CreateAnswerRequest): """ Answers the specified question using the provided documents and examples. The endpoint first [searches](/docs/api-reference/searches) over provided documents or files to find relevant context. The relevant context is combined with the provided examples and question to create the prompt for [completion](/docs/api-reference/completions). """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/audio/transcriptions', tags=['audio_transcription_and_translation', 'user_file_operations'], ) def create_transcription(file: UploadFile): """ Transcribes audio into the input language. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/audio/translations', tags=['audio_transcription_and_translation', 'user_file_operations'], ) def create_translation(file: UploadFile): """ Translates audio into into English. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post('/chat/completions', tags=['text_completion_services']) def create_chat_completion(body: CreateChatCompletionRequest): """ Creates a completion for the chat message """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/classifications', tags=['query_search_and_classification', 'text_completion_services'], ) def create_classification(body: CreateClassificationRequest): """ Classifies the specified `query` using provided examples. The endpoint first [searches](/docs/api-reference/searches) over the labeled examples to select the ones most relevant for the particular query. Then, the relevant examples are combined with the query to construct a prompt to produce the final label via the [completions](/docs/api-reference/completions) endpoint. Labeled examples can be provided via an uploaded `file`, or explicitly listed in the request using the `examples` parameter for quick tests and small scale use cases. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post('/completions', tags=['text_completion_services']) def create_completion(body: CreateCompletionRequest): """ Creates a completion for the provided prompt and parameters """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post('/edits', tags=['text_completion_services']) def create_edit(body: CreateEditRequest): """ Creates a new edit for the provided input, instruction, and parameters. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/embeddings', tags=['text_completion_services', 'query_search_and_classification'] ) def create_embedding(body: CreateEmbeddingRequest): """ Creates an embedding vector representing the input text. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get('/engines', tags=['model_registry_management']) def list_engines(): """ Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get('/engines/{engine_id}', tags=['model_registry_management']) def retrieve_engine(engine_id: str): """ Retrieves a model instance, providing basic information about it such as the owner and availability. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/engines/{engine_id}/search', tags=['query_search_and_classification', 'user_file_operations'], ) def create_search(engine_id: str, body: CreateSearchRequest = ...): """ The search endpoint computes similarity scores between provided query and documents. Documents can be passed directly to the API if there are no more than 200 of them. To go beyond the 200 document limit, documents can be processed offline and then used for efficient retrieval at query time. When `file` is set, the search endpoint searches over all the documents in the given file and returns up to the `max_rerank` number of documents. These documents will be returned along with their search scores. The similarity score is a positive score that usually ranges from 0 to 300 (but can sometimes go higher), where a score above 200 usually means the document is semantically similar to the query. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get('/files', tags=['user_file_operations']) def list_files(): """ Returns a list of files that belong to the user's organization. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post('/files', tags=['user_file_operations']) def create_file(file: UploadFile): """ Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact us if you need to increase the storage limit. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete('/files/{file_id}', tags=['user_file_operations']) def delete_file(file_id: str): """ Delete a file. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get('/files/{file_id}', tags=['user_file_operations']) def retrieve_file(file_id: str): """ Returns information about a specific file. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get('/files/{file_id}/content', tags=['user_file_operations']) def download_file(file_id: str): """ Returns the contents of the specified file """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/fine-tunes', tags=['model_registry_management', 'fine_tuning_job_management'] ) def list_fine_tunes(): """ List your organization's fine-tuning jobs """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/fine-tunes', tags=['fine_tuning_job_management', 'model_registry_management'] ) def create_fine_tune(body: CreateFineTuneRequest): """ Creates a job that fine-tunes a specified model from a given dataset. Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. [Learn more about Fine-tuning](/docs/guides/fine-tuning) """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/fine-tunes/{fine_tune_id}', tags=['fine_tuning_job_management', 'model_registry_management'], ) def retrieve_fine_tune(fine_tune_id: str): """ Gets info about the fine-tune job. [Learn more about Fine-tuning](/docs/guides/fine-tuning) """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/fine-tunes/{fine_tune_id}/cancel', tags=['fine_tuning_job_management', 'model_registry_management'], ) def cancel_fine_tune(fine_tune_id: str): """ Immediately cancel a fine-tune job. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get( '/fine-tunes/{fine_tune_id}/events', tags=['fine_tuning_job_management', 'model_registry_management'], ) def list_fine_tune_events(fine_tune_id: str, stream: Optional[bool] = False): """ Get fine-grained status updates for a fine-tune job. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post('/images/edits', tags=['visual_content_creation', 'user_file_operations']) def create_image_edit(file: UploadFile): """ Creates an edited or extended image given an original image and a prompt. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post('/images/generations', tags=['visual_content_creation']) def create_image(body: CreateImageRequest): """ Creates an image given a prompt. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post( '/images/variations', tags=['visual_content_creation', 'user_file_operations'] ) def create_image_variation(file: UploadFile): """ Creates a variation of a given image. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get('/models', tags=['model_registry_management']) def list_models(): """ Lists the currently available models, and provides basic information about each one such as the owner and availability. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.delete( '/models/{model}', tags=['model_registry_management', 'fine_tuning_job_management'] ) def delete_model(model: str): """ Delete a fine-tuned model. You must have the Owner role in your organization. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.get('/models/{model}', tags=['model_registry_management']) def retrieve_model(model: str): """ Retrieves a model instance, providing basic information about the model such as the owner and permissioning. """ raise RuntimeError("Should be patched by MCPProxy and never executed") @app.post('/moderations', tags=['text_content_moderation']) def create_moderation(body: CreateModerationRequest): """ Classifies if text violates OpenAI's Content Policy """ raise RuntimeError("Should be patched by MCPProxy and never executed") if __name__ == "__main__": parser = argparse.ArgumentParser(description="MCP Server") parser.add_argument( "transport", choices=["stdio", "sse", "streamable-http"], help="Transport mode (stdio, sse or streamable-http)", ) args = parser.parse_args() if "CONFIG_PATH" in os.environ: config_path = os.environ["CONFIG_PATH"] app.load_configuration(config_path) if "CONFIG" in os.environ: config = os.environ["CONFIG"] app.load_configuration_from_string(config) if "SECURITY" in os.environ: security_params = BaseSecurity.parse_security_parameters_from_env( os.environ, ) app.set_security_params(security_params) mcp_settings = json.loads(os.environ.get("MCP_SETTINGS", "{}")) app.get_mcp(**mcp_settings).run(transport=args.transport)

Latest Blog Posts

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/ag2-mcp-servers/openai-api'

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