context7

upstash/context7

4.9

context7 is hosted online, so all tools can be tested directly either in theInspector tabor in theOnline Client.

Context7 MCP provides up-to-date, version-specific documentation and code examples directly into your prompt, enhancing the capabilities of LLMs by ensuring they use the latest information.

Try context7 with chat:

MCPHub score:4.89

Has a README

Github repo has a README.md.

Has a License

Github repo has license info.

Server can be inspected

View server inspector

Server schema can be extracted

Can get at lease one tool info from the README or server.

Online hosted on MCPHub

Can be automatically deployed by MCPHub.

Has social accounts

Has X or Discord account.

Claimed by the author or certified by MCPHub

Connected with the author

AI Evaluation Report
Total Score: 9/10

The agent demonstrates strong capabilities in resolving library IDs and fetching detailed documentation for various libraries and packages. It effectively retrieves relevant content, including code snippets and descriptions, for libraries such as TensorFlow, PyTorch, Pandas, and Scikit-learn. The responses are generally accurate, comprehensive, and align well with the agent's described functions. However, there was a notable issue with the NumPy task, where inaccuracies in function signatures and misleading statements about changes were present. This indicates a potential limitation in handling certain libraries or modules with precision. Overall, the agent performs well in most tasks, providing useful and clear information, but there is room for improvement in ensuring accuracy and consistency across all libraries.

  • Test case 1
    Score: 10/10
    Perform the operation of resolving the library ID for 'TensorFlow' and then fetch the documentation focusing on the 'Keras API' topic, retrieving up to 10,000 tokens of content.

    The library ID for "TensorFlow" has been successfully resolved, and I have retrieved comprehensive documentation focusing on the "Keras API." Below are some key sections and code snippets from the documentation:

    Key Sections and Code Snippets

    1. Keras Model Architectures
      • Description: Keras offers multiple ways to define model architectures, including the Sequential API, the Functional API, and subclassing.
      • Code:
        # Sequential Model
        model = tf.keras.Sequential([
            tf.keras.layers.Dense(64, activation='relu', input_shape=(784,)),
            tf.keras.layers.Dense(10, activation='softmax')
        ])
        
    2. Keras Functional API Model Construction
      • Description: Illustrates building a fully-connected network using the Functional API.
      • Code:
        inputs = tf.keras.Input(shape=(32,))
        x = layers.Dense(64, activation='relu')(inputs)
        predictions = layers.Dense(10, activation='softmax')(x)
        model = tf.keras.Model(inputs=inputs, outputs=predictions)
        
    3. Compile Keras Model
      • Description: API documentation for compiling a Keras model.
      • Code:
        model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
        
    4. Keras Callbacks
      • Description: Callbacks can be used during training for tasks like early stopping and model checkpointing.
      • Code:
        callbacks = [
            tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=3),
            tf.keras.callbacks.ModelCheckpoint('best_model.h5', save_best_only=True)
        ]
        model.fit(x_train, y_train, callbacks=callbacks)
        
    5. Evaluate Model with Model.evaluate
      • Code:
        model.evaluate(eval_dataset, return_dict=True)
        
    6. Train Model with Model.fit
      • Description: Demonstrates training a Keras model using the fit method.
      • Code:
        model.fit(dataset)
        

    Additional Information

    • Keras Integration with TensorFlow: Keras serves as a high-level API integrated into TensorFlow, facilitating easy model building and training.
    • Deployment: Keras models can be exported for use in various environments, including browsers and mobile devices. For a complete exploration of the Keras API, you can refer to the full documentation, which includes more detailed examples and additional topics such as performance optimization, custom layers, and advanced model configurations.
  • Test case 2
    Score: 10/10
    Perform the operation of resolving the library ID for 'PyTorch' and then fetch the documentation focusing on the 'torch.nn' module, retrieving up to 10,000 tokens of content.

    The library ID for 'PyTorch' has been successfully resolved, and the documentation focusing on the torch.nn module has been retrieved. Highlights include:

    1. BatchNorm Fusion Utilities
      • Description: API documentation for utility functions in torch.nn.utils to fuse Convolutional or Linear Modules with BatchNorm modules, optimizing inference performance.
      • Code Snippet:
        fuse_conv_bn_eval
        fuse_conv_bn_weights
        fuse_linear_bn_eval
        fuse_linear_bn_weights
        
    2. nn.Linear Module API Documentation Style Example
      • Description: This example demonstrates the required docstring format for torch.nn modules, detailing the nn.Linear module's API and its mathematical transformation.
      • Code Snippet:
        Applies a linear transformation to the incoming data.
        y = xA^T + b
        
    3. Loss Functions
      • Description: Comprehensive set of PyTorch's loss functions used for training neural networks.
      • Code Snippet:
        nn.L1Loss
        nn.MSELoss
        nn.CrossEntropyLoss
        
    4. Neural Network Submodules
      • Description: Lists various submodules within the torch.nn package for different functionalities.
      • Code Snippet:
        torch.nn.modules.activation
        torch.nn.modules.batchnorm
        torch.nn.modules.dropout
        
    5. RNN Utilities
      • Description: API documentation for utility functions and classes in torch.nn.utils.rnn for handling variable-length sequences in RNNs.
      • Code Snippet:
        nn.utils.rnn.PackedSequence
        nn.utils.rnn.pack_padded_sequence
        
    6. Parameter Initialization Utilities
      • Description: Utility functions in torch.nn.utils for initializing Module parameters.
      • Code Snippet:
        skip_init
        
    7. DataParallel Layers
      • Description: API documentation for PyTorch's data parallelism modules for distributing model training across multiple GPUs.
      • Code Snippet:
        nn.DataParallel
        nn.parallel.DistributedDataParallel
        

    The documentation includes extensive details on various utilities, loss functions, and modules within the torch.nn package, allowing you to effectively utilize PyTorch for building and training neural networks.

  • Test case 3
    Score: 5/10
    Perform the operation of resolving the library ID for 'NumPy' and then fetch the documentation focusing on the 'numpy.linalg' module, retrieving up to 10,000 tokens of content.

    The library ID for 'NumPy' has been successfully resolved, and the documentation for the numpy.linalg module has been retrieved. Below is a summary of the relevant content and code snippets from the documentation:

    NumPy linalg Module Overview

    The numpy.linalg module includes various functions for linear algebra, including matrix and vector operations. Here's a selection of notable functions and changes:

    1. Matrix Norms:
      numpy.linalg.matrix_norm(x, ord=None, keepdims=False)
      
      Computes the matrix norm of a matrix (or a stack of matrices).
    2. Vector Norms:
      numpy.linalg.vector_norm(x, ord=None, axis=None, keepdims=False)
      
      Computes the vector norm of a vector (or batch of vectors).
    3. Dot Products:
      numpy.vecdot(x1, x2, *, axis=None)
      
      Computes the dot product of two arrays.
    4. Outer Products:
      numpy.linalg.outer(x1, x2)
      
      Computes the outer product of two vectors.
    5. Cross Products:
      numpy.linalg.cross(x1, x2, *, axis=-1)
      
      Computes the cross product of two (arrays of) 3-dimensional vectors.

    Notable Changes and Features

    • Backward Compatibility: Some functions were relocated to numpy.linalg, and their behavior was updated to support stacking and batching, affecting how they operate on multiple dimensions.

    • NamedTuples: Functions within np.linalg that previously returned standard tuples now return NamedTuples, improving code readability.

    • Performance Improvements: Functions like np.linalg.det and np.linalg.svd have been optimized for better performance, particularly when dealing with large matrices.

    • Function Enhancements: New arguments such as hermitian for numpy.linalg.pinv enable faster computations for Hermitian matrices.

    Example Usage

    Here’s an example of how to use some of the numpy.linalg functions:

    import numpy as np
    # Define a matrix
    matrix = np.array([[1, 2], [3, 4]])
    # Calculate the determinant
    det = np.linalg.det(matrix)
    # Perform Singular Value Decomposition (SVD)
    u, s, vh = np.linalg.svd(matrix)
    print(f"Determinant: {det}")
    print(f"Singular values: {s}")
    

    Further Reading

    For more detailed documentation, you can visit the NumPy Documentation that covers all functionalities provided by the numpy.linalg module.

  • Test case 4
    Score: 9/10
    Perform the operation of resolving the library ID for 'pandas' and then fetch the documentation focusing on the 'DataFrame' class, retrieving up to 10,000 tokens of content.

    I successfully resolved the library ID for 'pandas' and retrieved documentation focusing on the 'DataFrame' class. Below are some excerpts from the documentation, including code snippets and descriptions related to the 'DataFrame' class in Pandas:

    Key Concepts and Code Snippets

    1. DataFrame Arithmetic: DataFrame + DataFrame
      • Description: Demonstrates arithmetic operations between two DataFrames. Pandas automatically aligns them on both column and index labels.
      • Code:
        df = pd.DataFrame(np.random.randn(10, 4), columns=["A", "B", "C", "D"])
        df2 = pd.DataFrame(np.random.randn(7, 3), columns=["A", "B", "C"])
        df + df2
        
    2. Create DataFrame from Series
      • Description: Converts a Pandas Series into a DataFrame. The DataFrame will have the same index as the Series.
      • Code:
        ser = pd.Series(range(3), index=list("abc"), name="ser")
        pd.DataFrame(ser)
        
    3. DataFrame Combining, Comparing, Joining, and Merging
      • Description: Methods for combining DataFrames, comparing elements, joining based on indices, and merging based on common columns.
      • Code:
        DataFrame.assign(**kwargs)
        DataFrame.compare(other)
        DataFrame.join(other)
        DataFrame.merge(right)
        
    4. Sample Pandas DataFrame Structure
      • Description: A textual representation of a pandas DataFrame, illustrating its index and a single column of data.
      • Code:
        a
        0
        0
        1
        1
        ...
        
    5. DataFrame Operations
      • Description: Demonstrates common operations on DataFrame columns, including selection, addition, deletion, and assignment.
      • Code:
        df["new_col"] = value  # Assign a scalar value
        del df["column_name"]  # Delete column by name
        
    6. DataFrame Missing Data Handling
      • Description: Methods for detecting, filling, and dropping missing (NaN) values in a DataFrame.
      • Code:
        df.dropna(axis=0)
        df.fillna(value=0)
        

    Additional Features

    • Statistical Functions: Methods for calculating various statistical measures, including mean, median, standard deviation, and more.
    • Merging and Joining: Extensive capabilities for merging and joining DataFrames based on common columns. This documentation provides a comprehensive overview of the functionality offered by the DataFrame class in Pandas, including numerous examples that can be readily utilized in data analysis tasks.
  • Test case 5
    Score: 10/10
    Perform the operation of resolving the library ID for 'scikit-learn' and then fetch the documentation focusing on the 'RandomForestClassifier' class, retrieving up to 10,000 tokens of content.

    The library ID for scikit-learn has been successfully resolved, and the documentation for the RandomForestClassifier class has been retrieved. Below are key details and code snippets from the documentation:

    Library Information

    • Library Name: Scikit-learn
    • Library ID: /scikit-learn/scikit-learn
    • Description: scikit-learn: machine learning in Python
    • Code Snippets Available: 3040
    • Trust Score: 8.5

    Documentation for RandomForestClassifier

    Here are some notable code snippets and their descriptions:

    1. Initialize and Fit Scikit-learn RandomForestClassifier
      from sklearn.ensemble import RandomForestClassifier
      X = [[0, 0], [1, 1]]
      Y = [0, 1]
      clf = RandomForestClassifier(n_estimators=10)
      clf = clf.fit(X, Y)
      
      • Description: Demonstrates basic usage by importing the class, defining training data, and fitting the model.
    2. Incrementally Fit RandomForestClassifier with warm_start
      from sklearn.datasets import make_classification
      from sklearn.ensemble import RandomForestClassifier
      X, y = make_classification(n_samples=100, random_state=1)
      clf = RandomForestClassifier(n_estimators=10)
      clf = clf.fit(X, y)  # fit with 10 trees
      clf.set_params(n_estimators=20, warm_start=True)
      clf.fit(X, y)  # fit additional 10 trees
      
      • Description: Shows how to use warm_start=True to add more trees to an already fitted model.
    3. Evaluate Random Forest Classifier Performance with Cross-Validation
      from sklearn.ensemble import RandomForestClassifier
      from sklearn.model_selection import cross_val_score
      clf = RandomForestClassifier(n_estimators=10)
      scores = cross_val_score(clf, X, y, cv=5)
      print(scores.mean())
      
      • Description: Applies 5-fold cross-validation to assess the model's performance.
    4. RandomForestClassifier: Equivalence of Single vs. Iterative Training
      clf = RandomForestClassifier(n_estimators=20)  # set `n_estimators` to 10 + 10
      clf.fit(X, y)  # fit
      
      • Description: Illustrates that training once with total estimators is equivalent to building iteratively.
    5. Fix: RandomForestClassifier Predict Method for Multioutput
      ensemble.RandomForestClassifier: Fix class_weight='balanced_subsample' with >32 classes
      
      • Description: Corrects a bug in the predict method for multiclass multioutput configurations. These snippets illustrate different functionalities and improvements related to the RandomForestClassifier. If you would like more specific information or additional snippets, please let me know!